I have changed the dbpath of mongodb.conf. And after that trying to start mongodb service,when I run

sudo service mongodb start

I get back

mongodb start/running, process 7320

After that I run:

sudo service mongodb status

And getting back

mongodb stop/waiting

When I want to access mongo shell by :

MongoDB shell version: 2.0.4
connecting to: test
Sun Oct 28 13:01:36 Error: couldn't connect to server shell/mongo.js:84
exception: connect failed

But when I start mongod as manually by mongod --dbpath=/mnt/data/db it runs fine. And I can access the mongo shell by mongo command.

I have correct permission for my data directory.

Any clue where I am doing wrong?

  • Same problem for me. Did you ever figure out a solution?
    – gozzilli
    Commented Sep 24, 2015 at 16:10

3 Answers 3


It is possible that mongodb.conf is not getting loaded because of wrong location (typically this is /etc/mongodb.conf) or a typo when you launch through service start

Try launching manually

mongod --config /etc/mongodb.conf

to rule out any issues with the conf file.

  • no issue with conf file,it works fine when I do mongod --config /etc/mongodb.conf
    – arnold
    Commented Oct 28, 2012 at 17:16

Also check the owner of the old path and compare it to the owner of the new path with ls -la. It's possible that you created the new dbpath as a different user than mongodb runs as, so you would need to use chown to change the owner.


Check the config file there will be bind-ip and port pass that value while connecting to client

mongo <ip.add.re.ss>:<port>/<dbname> 

assume ip is and port is 27017

  • The question is about the configuration file location, not IP address.
    – mustaccio
    Commented Jul 10, 2015 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.