title: Unable to connect to mongodb Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
body: <p>When ever I try to connect to mongo db I always get this error as below. </p>
  
  <p>MongoDB shell version: 2.4.3
  connecting to: test
  Fri Apr 26 14:31:46.941 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
  exception: connect failed</p>
  
  <p>I tried various solutions listed in stackoverflow and tried following commands but nothing works. </p>
  
  <p>1) sudo rm /var/lib/mongodb/mongod.lock </p>
  
  <p>// says such file located at this place. </p>
  
  <p>2)  sudo service mongodb start  </p>
  
  <p>// error: sudo: service: command not found</p>
  
  <p>3) I've made sure nothing else is running at that port. </p>
  
  <p>4) Even tried uninstalling and installing it again. </p>
  
  <p>5) Also tried kill pid</p>