Timeout when starting Mongo as a service


I’m currently maintaining the company’s mongodb cluster and have just upgraded it to 4.4. If I run it directly using “mongod” everything works just fine, but I wanted to leave it running as a service for the ease of maintenance, set up to start if it’s rebooted, etc.

The issue I’m facing is that once I start mongo with the usual “service mongod start” (CentOS7) it times out. By checking the logs I’ve seen that it actually starts no problem, even receives connections and everything works fine, but it looks like it’s missing an “ok” for systemctl to consider the service has actually started, therefore it hangs forever and times out.

Has anyone faced this before? Is there something I’m missing?

By the way, I’ve just reinstalled it to make sure I didn’t mess up the “.service” file or anything like that, and the issue persists.


Were you able to solve this problem? I’m facing the same issue with CentOS7.

Unfortunately I haven’t find a solution yet. Something I noticed was that the pid file was not the same in the service definition and the config file, so I changed it to make them match but the problem persists. I also increased the timeout for the service to wait a bit longer (TimeoutStartSec=400 in mongod.service) but it didn’t help either.

As a workaround I had to disable the service and run it “manually” from /etc/rc.local, but I would prefer to apply a proper fix and run it as a service.


Hello everyone,

I am facing the same issue, running from command line works , even my data is replicated across the nodes and everything is synced and running.
However, starting it as service and with (TimeoutStartSec=400 in mongod.service) leaves it working for those 400secs (the files are also fully replicated and properly inserted inside those 400 seconds). I also see no issue in log files, so if anyone can contribute to this issue it would be helpful !

@Daniel_Sales I’m sorry, I’ve missed your inquiry there, but after a couple days searching I gave up and actually created and configured my own service on every node (now I start my “mongo-service” there and everything works). I haven’t actually tried it again after that incident since one way or another, it worked.

No problem,

It didn’t take long for me to find a solution , it was a missing PID file required for the service to run.

Issue was fixing by adding the following line to the configuration file under the “processManagement”:

  pidFilePath: /var/run/mongodb/mongod.pid

Followed by systemctl daemon-reload, and reverting my TimeoutStartSec to 60seconds to make sure it is working after the given time. Hopefully it will help someone