Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apt cannot find mongodb-org on Ubuntu

ErrorE: Unable to locate package mongodb-org

Short answer

Ubuntu's own package lists do not contain mongodb-org. It comes from MongoDB's own apt repository, so apt only finds it after you import the key, add the repository line for your Ubuntu codename and run apt-get update. Also confirm the release is a 64-bit LTS that MongoDB lists as supported.

  • Applies to MongoDB Community 8.0, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask apt whether any repository offers the package, and check which Ubuntu release and CPU you are on.

    apt-cache policy mongodb-org
    cat /etc/lsb-release
    dpkg --print-architecture
  2. 2Match what you see, then jump to its fix

    1. 1apt-cache policy mongodb-org prints nothing, and /etc/apt/sources.list.d/ has no mongodb-org fileThe MongoDB repository was never added, or apt update was not run after adding itFix
    2. 2The repository line is correct and apt update ran, but apt-cache policy still shows no candidateThe Ubuntu release or CPU is not one MongoDB supportsFix
    3. 3The package stays missing even though apt update ran, and the repository file names another codenameThe repository line names a different codename than your Ubuntu releaseFix

What does the error look like?

  • E: Unable to locate package mongodb-org
  • Unable to locate package mongodb-org (after sudo apt-get install mongodb-org)

Cause 1 of 3

The MongoDB repository was never added, or apt update was not run after adding it

1Check

Look for the repository file MongoDB's guide creates. If it is missing, or you created it but did not reload the package lists, apt has nothing to search.

ls /etc/apt/sources.list.d/ | grep -i mongodb

2Fix

Import the signing key, create the repository file for your Ubuntu codename (noble is 24.04), reload the package lists and install.

sudo apt-get install gnupg curl
curl -fsSL https://pgp.mongodb.com/server-8.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

3Verify

apt now shows a candidate version that comes from repo.mongodb.org.

apt-cache policy mongodb-org

Confirmed by mongodb.com

Did this fix it?

Cause 2 of 3

The Ubuntu release or CPU is not one MongoDB supports

1Check

MongoDB 8.0 on Ubuntu lists 64-bit LTS releases only: 24.04, 22.04 and 20.04, on x86_64 and on selected ARM64 platforms. Anything outside that list, such as a non-LTS release or a 32-bit system, is not covered by the guide, so do not expect packages.

cat /etc/lsb-release
dpkg --print-architecture

2Fix

Use a supported 64-bit LTS release. On an unsupported machine, run MongoDB in another way, for example on a supported host or in a container, instead of forcing the repository.

# Supported codenames in the repository line: noble, jammy, focal

3Verify

On a supported release, apt-cache policy lists a candidate from repo.mongodb.org.

apt-cache policy mongodb-org

Confirmed by mongodb.com

Did this fix it?

Cause 3 of 3

The repository line names a different codename than your Ubuntu release

1Check

The line contains the Ubuntu codename and the MongoDB series. For Jammy or Focal you replace noble in the line with jammy or focal. A line copied from another guide may name the wrong one.

cat /etc/apt/sources.list.d/mongodb-org-8.0.list
lsb_release -cs

2Fix

Rewrite the file so the codename in it matches your release, then reload the package lists.

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

3Verify

apt-cache policy mongodb-org shows a candidate.

apt-cache policy mongodb-org

Confirmed by mongodb.com

Did this fix it?

How do I stop it coming back?

  • Follow the installation page for your exact MongoDB series and add the repository file it names, instead of reusing a line from an older server.
  • Run apt-get update every time you add or edit a file in /etc/apt/sources.list.d/.
  • Do not install Ubuntu's own mongodb package next to mongodb-org: MongoDB says the two conflict, so remove it first.
  • Pick a supported 64-bit LTS release for new MongoDB servers.

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

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

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