Mongod service restart

Hi, I found it that need to stop the mongod service first and then start the service instead restart the service at once. is this a normal or am i doing something wrong?

that is normal for mongod. it won’t ever start if an error is present in settings, and will just work unless something unexpected happens. you can also have multiple instances running for different purposes, so a single stop/restart command would just not work.

for that reason, you need to login individually to each instance and invoke “shutdown” from “admin” database if you need to stop the server. or you may just kill the process if it is just a test server.

Hi @Rajitha_Hewabandula ,

You should be able to restart the service as long as you started the mongod process using a service wrapper. For example, on Linux:

sudo service mongod start
sudo service mongod restart

If you are having difficulties restarting, please provide some more details:

  • Your O/S version
  • Your MongoDB server version
  • The commands you ran to start and restart mongod
  • Any error messages or output displayed when mongod fails to restart


1 Like

You could start/stop/restart multiple instances individually with systemctl if you create the appropriate systemd unit files.
You could even start/stop/restart multiple instances all at once with an appropriate systemd unit file.

Make sure you use the appropriate signal when you kill the process. Some files, like /tmp/mongodb-27017.sock and some lock files in the db directory, might remains if the wrong signal is used with kill. And you might not be able to restart. The appropriate signal SIGTERM.


@steevej @Yilmaz_Durmaz Thanks for the prompt reply. its totally fine with the production server. this was happened in the VM machine. :slightly_smiling_face: