Easy way to fix MongoDB Error: "couldn't connect to server 127.0.0.1:27017"(In Windows OS)

·

1 min read

The MongoDB error below usually caused by the MongoDB service is stopped:

Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. : connect@src/mongo/shell/mongo.js:372:17 @(connect):2:6 exception: connect failed exiting with code 1

Share an easy way to fix that:

  • Press Ctrl + Shift + Esc, open Task manager

  • Open the Services tab, locate MongoDB

  • Right-click and select Start