Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

systemctl cannot find mongod.service on Ubuntu

ErrorFailed to start mongod.service: Unit mongod.service not found.

Short answer

The mongod.service unit comes from MongoDB's own mongodb-org package. If systemd cannot find it, that package is not installed: the apt source is missing or wrong, or the older Ubuntu mongodb package is in the way. Add MongoDB's repository, install mongodb-org, then start mongod.

  • Applies to MongoDB 9.0 Community, Ubuntu with systemd
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See which MongoDB packages apt knows about and whether the repository list file exists.

    apt list --installed 2>/dev/null | grep -i mongo
    ls /etc/apt/sources.list.d/ | grep -i mongo
  2. 2Match what you see, then jump to its fix

    1. 1Unable to locate package mongodb-org, or no mongodb-org line in the installed listmongodb-org is not installed, or the apt repository is missing or wrongFix
    2. 2apt or dpkg reports trying to overwrite /usr/bin/mongod, or both packages show in the installed listThe distribution's mongodb package conflicts with mongodb-orgFix

What does the error look like?

  • Failed to start mongod.service: Unit mongod.service not found.
  • Unable to locate package mongodb-org

Cause 1 of 2

mongodb-org is not installed, or the apt repository is missing or wrong

1Check

The list file for your Ubuntu release must match the MongoDB install guide exactly. If it is missing or differs, apt cannot find the package.

cat /etc/apt/sources.list.d/mongodb-org-9.0.list

2Fix

Import the key, recreate the list file with the line the guide gives for your Ubuntu release, then install and start the service.

sudo apt-get install gnupg curl
curl -fsSL https://pgp.mongodb.com/server-9.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-9.gpg --dearmor
# create /etc/apt/sources.list.d/mongodb-org-9.0.list with the line from the guide
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod

3Verify

The status shows mongod.service loaded and active.

systemctl status mongod

Confirmed by mongodb.com

Did this fix it?

Cause 2 of 2

The distribution's mongodb package conflicts with mongodb-org

1Check

List installed MongoDB packages. The guide says the distribution's mongodb package is not maintained by MongoDB and conflicts with mongodb-org.

sudo apt list --installed | grep mongo

2Fix

Back up any edited configuration, remove the distribution package, then install mongodb-org again. If both are present, remove mongodb-org first.

sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove
sudo apt install -y mongodb-org

3Verify

Start the service and check it.

sudo systemctl start mongod
systemctl status mongod

Confirmed by mongodb.com

Did this fix it?

How do I stop it coming back?

  • Install MongoDB only from the repository shown in MongoDB's own install guide for your Ubuntu release.
  • Do not install the distribution's mongodb package on a server meant for mongodb-org.
  • Run sudo systemctl enable mongod so it starts after a reboot.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.