3

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 :

 mongo
MongoDB shell version: 2.0.4
connecting to: test
Sun Oct 28 13:01:36 Error: couldn't connect to server 127.0.0.1 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?

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

3 Answers 3

1

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.

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

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.

-1

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 10.10.10.2 and port is 27017

mongo 10.10.10.2:27017/test
1
  • The question is about the configuration file location, not IP address.
    – mustaccio
    Jul 10, 2015 at 19:25

Your Answer

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