Menu

How to Install MongoDB 8.0 on Ubuntu 20.04

Install MongoDB 8.0 Community Edition on Ubuntu 20.04 from MongoDB’s APT repository, verify mongod with mongosh, and check Ubuntu Pro coverage.

Posted on By Updated on
On this page

MongoDB 8.0 Community Edition supports Ubuntu 20.04 LTS (Focal Fossa) on 64-bit x86. Ubuntu 20.04 standard security maintenance ended on May 31, 2025. Ubuntu Pro Expanded Security Maintenance (ESM) extends Ubuntu package security updates through May 2030; MongoDB packages receive updates from MongoDB’s own APT repository. For new deployments, prefer a currently supported Ubuntu LTS release. See MongoDB’s Ubuntu installation guide and Canonical’s Ubuntu security maintenance schedule.

Ubuntu’s separate mongodb package is not maintained by MongoDB and conflicts with the official mongodb-org package. If it is installed, remove it before proceeding. If this system already contains MongoDB data, make and verify a backup before replacing packages.

Prerequisites

  • Ubuntu 20.04 LTS (Focal) on amd64.
  • A user account with sudo privileges.
  • Internet access.
  • A fresh MongoDB installation, or a verified backup and upgrade plan for any existing data.

Add MongoDB’s APT Repository

Install gnupg and curl if they are not already available:

sudo apt-get update
sudo apt-get install -y gnupg curl

Import MongoDB’s public signing key into an APT keyring:

curl -fsSL https://pgp.mongodb.com/server-8.0.asc | \
  sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

Add the MongoDB 8.0 repository for Ubuntu 20.04:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 multiverse" | \
  sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

Refresh APT’s package index and check that mongodb-org is available from MongoDB’s repository:

sudo apt-get update
apt-cache policy mongodb-org

The candidate should be an 8.0 release from repo.mongodb.org. MongoDB publishes maintenance updates within the 8.0 series, so the patch version may change.

Install MongoDB Community Edition

Install the official metapackage and its components:

sudo apt-get install -y mongodb-org

Start and Verify MongoDB

Enable the mongod service at boot and start it:

sudo systemctl enable --now mongod

Check the service status and query the server version:

sudo systemctl status mongod --no-pager
mongosh --quiet --eval 'db.version()'

Connect to the local server with the MongoDB Shell:

mongosh

Manage the MongoDB Service

Use systemctl to manage the server:

sudo systemctl start mongod
sudo systemctl stop mongod
sudo systemctl restart mongod
sudo systemctl status mongod --no-pager

Troubleshooting

  • If APT cannot find mongodb-org, run sudo apt-get update and check that /etc/apt/sources.list.d/mongodb-org-8.0.list names the focal/mongodb-org/8.0 repository and amd64 architecture.
  • If mongod does not start, check sudo systemctl status mongod --no-pager and review recent service logs with sudo journalctl -u mongod -e --no-pager.
  • MongoDB binds to localhost by default. Before allowing remote connections, configure authentication and network controls as described in MongoDB’s production notes.

Conclusion

You installed MongoDB 8.0 Community Edition on Ubuntu 20.04 from MongoDB’s signed APT repository. Ubuntu 20.04 requires Ubuntu Pro ESM for continued security updates. For newer LTS releases, see our Ubuntu 22.04 guide or Ubuntu 24.04 guide.