Recently I’ve got the following issue:
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:374:17 @(connect):2:6 exception: connect failed exiting with code 1
Obviously, as most error messages, above is not clear about the root cause. Finally, I’ve resolved it by using following steps:
- Go to
/usr/local/var/mongodb
- Remove file
mongod.lock
. On MacOS:rm mongod.lock
- Restart MongoDB using brew command (if MongoDB were installed using brew):
brew services restart mongodb-community
I hope this helps someone to save their time in finding a solution to that issue.
Leave a Reply