Failed to start mongod.service: Unit mongod.service not found. – Ubuntu 16.04

Recently, I installed MongoDB following the tutorial on their site on Ubuntu 16.04 64 bit. But when trying to start the mongod service I got the following error: “Failed to start mongod.service: Unit mongod.service not found.”

To resolve it I followed the solution suggested on StackOverflow.

Create the configuration file for MongoDB

sudo nano /etc/systemd/system/mongodb.service

Add the following content to the file

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

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

[Install]
WantedBy=multi-user.target

Run the mongod service

sudo systemctl start mongodb
sudo systemctl status mongodb

Make the service permanent

sudo systemctl enable mongodb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s