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


1 min read

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

Error: couldn't connect to server, connection attempt failed: SocketException: Error connecting to :: 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