Error: couldn’t connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js: exception: connect failed

March 9, 2013

Error: couldn’t connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js: exception: connect failed 

As a learner in mongodb I don’t get understand why this problem often occur in Linux machine. But Luckily somehow I figured out a way to resolve this issue with the help of few mongodb experts outs there on internet. Below is the way I followed to put an end to the starting trouble of mongodb. 

Step 1) Remove lock file.
sudo rm /var/lib/mongodb/mongod.lock

Step 2) Repair mongodb.
mongod –repair

Step 3) start mongodb.
sudo service mongodb start
(or)
sudo start mongodb

Step 4) Check status of mongodb.
sudo service mongodb status
(or)
sudo status mongodb

Step 5) Start mongo console.
mongo

that’s it,above commands would have instructed mongodb to repair the broken piece and start the new instance for us to continue.

  • Philippe Thomas

    Simply the best way I ve found so far to fix the problem, I had really no clue how it happened tough.

    Thanks Mate !

 
Intolerance of your present creates your future – Mike Murdock

@shakthydoss