i need help with a problem on shutting mongod down gracefully. I'm running mongodb on docker .

i run mongod like with the command :

mongod --config /etc/mongod.conf

and when i close with :

mongod --shutdown

i get the message :

There doesn't seem to be a server running with dbpath: /data/db

the message is true , because my db path is not "/data/db" .

and if i try to shut it down like :

mongod --config /etc/mongod.conf --shutdown

i get the message:

killing process with pid: 9

what is the problem ?


I have found that if you aren't using the default --dbpath, you have to specify it as part of the shutdown. For example, if you start the mongod service with /Mongo/Data as the dbpath you have to shut it down with:

mongod --dbpath /Mongo/Data --shutdown

This works even if you aren't using the default port of 27017.


You can just use :

pskill mongod

Or for some *nix and linux distros:

pkill mongod

When mongod gets the SIGTERM command(default signal of kill command is SIGTERM), it will shutdown the database gracefully.

You can also check the PID of the mongod process with :

ps -ef | grep mongod

Then shutdown by:

kill <PID of mongod>

But DO NOT use kill -9 for mongod process.

  • 6
    pskill might be available as pkill on some machines (including my own) – Joshua Jul 3 '15 at 15:27

It could also be that your mongod is running as a service, you can simply try:

sudo service mongod stop

And sudo service mongod start to start again. There is also status and restart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.