systemctl cannot find mongod.service on Ubuntu
Failed 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.
Fix it fast
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 mongo2Match what you see, then jump to its fix
- 1
Unable 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
apt 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
- 1
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.list2Fix
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 mongod3Verify
The status shows mongod.service loaded and active.
systemctl status mongodConfirmed by mongodb.com
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 mongo2Fix
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-org3Verify
Start the service and check it.
sudo systemctl start mongod
systemctl status mongodConfirmed by mongodb.com
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
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fixDatabases
manage.py test stops with 'permission denied to create database' on PostgreSQL
django.db.utils.ProgrammingError: permission denied to create database
Django creates a separate database called test_ plus your database name, using the DATABASES USER.
2 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fix