Connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017

MongoDB shell version v5.0.14
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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 :: Connection refused :
connect@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1

there are two possible causes for your problem:

  • your server is not running, make sure it is up and healthy.
  • it is not configured to listen “127.0.0.1”. by default, it is set to listen to requests coming for localhost name, not with IP number.

This topic was automatically closed after 180 days. New replies are no longer allowed.