Tuesday 2 February 2016

Resolve the connection problem of MongoDB

I was trying to connect to mongoDB and was getting the following error :


MongoDB shell version: 2.6.11
connecting to: test
2016-02-03T10:23:22.010+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-02-03T10:23:22.011+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

I resoved the above issue by issuing the following command in MongoDB


  • sudo rm /var/lib/mongodb/mongod.lock
  • sudo service mongod restart