Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Oct 29 '12 at 17:53

This question came from our site for professional and enthusiast programmers.

Same problem for me. Did you ever figure out a solution? – gozzilli Sep 24 '15 at 16:10

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.

share|improve this answer
no issue with conf file,it works fine when I do mongod --config /etc/mongodb.conf – arnold Oct 28 '12 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.

share|improve this answer

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

mongo <>:<port>/<dbname> 

assume ip is and port is 27017

share|improve this answer
The question is about the configuration file location, not IP address. – mustaccio Jul 10 '15 at 19:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.