How Do You Troubleshoot Mongodb when It Will Not Start and You Get This Error “Failed to start mongodb.service: Unit mongodb.service not found.”?

Problem scenario
Using Linux you try to start the Mongodb service, but the service fails to start.  You get this error: "Failed to start mongodb.service: Unit mongodb.service not found."  How do you fix this problem?

Solution
Verify you have this file: /etc/systemd/system/mongodb.service
Verify it has this content (with the last line being the "WantedBy=multi-user.target" stanza):

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

With Ubuntu 16 the command "systemctl start mongodb" (as root with no quotes) should start the Mongodb service.

See what version of Mongo you have installed by going to this link.

Leave a comment

Your email address will not be published. Required fields are marked *