Mongodb not shutting down via --shutdown command

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.