Error: couldn’t connect to server 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
sudo start mongodb

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

Step 5) Start mongo console.

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