After installing Mongodb , You may face the following error when use mongodb from terminal:

mongo.js:L112 Error: couldn't connect to server at src/mongo/shell/mongo.js:L112

If you are running Ubuntu, then there is an issue with folder ownership.
Run these commands:
  1. Stop mongodb service
    sudo service mongodb stop
  2. Remove mongodb lock file
    sudo rm /var/lib/mongodb/mongod.lock
  3. Change ownership from root to mongodb path
    sudo chown -R mongodb:mongodb /var/lib/mongodb/
  4. Start mongodb service
    sudo service mongodb start
  5. Test mongo app
Then you will be able to execute successfully (i hope).

 Source : stackoverflow