Skip to content

Fix: E: Unable to locate package (apt-get install on Ubuntu/Debian)

FixDevs ·

Quick Answer

How to fix the 'E: Unable to locate package' error in apt-get on Ubuntu and Debian, including apt update, missing repos, Docker images, PPA issues, and EOL releases.

The Error

You try to install a package with apt-get or apt and get:

E: Unable to locate package some-package

Or one of these variations:

E: Unable to locate package nodejs
E: Unable to locate package python3-pip
E: Unable to locate package libssl-dev
E: Package 'some-package' has no installation candidate
E: Unable to locate package software-properties-common

Why This Happens

APT (Advanced Package Tool) resolves packages by searching through package index files stored locally on your system. These index files are essentially catalogs that list every package available from the repositories configured in /etc/apt/sources.list and /etc/apt/sources.list.d/. When you run apt-get install, APT looks through these local catalogs to find the package you requested.

The “Unable to locate package” error means APT searched through all its local index files and could not find a package matching the name you provided. This can happen for several reasons:

  • The local package index is outdated or empty. You never ran apt-get update, or it was run so long ago that the cached index no longer reflects what the repositories offer.
  • The package name is wrong. You have a typo, or the package is named differently than you expect on your distribution or version.
  • The repository containing the package is not enabled. Many packages live in universe, multiverse, or third-party PPAs that are not configured by default.
  • Your Ubuntu or Debian version is too old. End-of-life releases have their repositories moved to an archive server, making the default URLs return errors.
  • You are inside a minimal Docker container. Official Docker base images ship with no package index at all to keep image sizes small.
  • A network issue is preventing APT from reaching the repository servers. Firewalls, proxies, or DNS misconfigurations can silently block access.

Understanding which of these causes applies to your situation is the key to choosing the right fix.

Fix 1: Run apt-get update First

This is the single most common fix. The local package index is either stale or completely empty (especially in Docker containers and fresh installs). Running apt-get update downloads the latest package lists from all configured repositories:

sudo apt-get update

Then retry the install:

sudo apt-get install some-package

The update command does not install or upgrade any packages — it only refreshes the catalog. Think of it as downloading the latest menu from a restaurant before placing your order. Without an up-to-date menu, the restaurant (APT) has no idea what it can serve you.

If apt-get update itself fails with errors like “Failed to fetch” or “Could not resolve,” you have a network or repository configuration problem. Check the fixes below for proxy/firewall issues and outdated sources lists.

You can combine update and install in a single command to make sure the index is always fresh:

sudo apt-get update && sudo apt-get install -y some-package

Fix 2: Check the Package Name

Package names on Debian and Ubuntu do not always match what you expect. A typo or a naming convention mismatch can lead to “Unable to locate package” even when the package absolutely exists in the repositories.

Search for the correct name:

apt-cache search keyword

For example, if you want to install Python’s pip:

apt-cache search python3 | grep pip

This might show that the package is called python3-pip, not pip or pip3.

Common naming pitfalls:

What you triedCorrect package name
pythonpython3
pippython3-pip
nodenodejs
mysqlmysql-server or mariadb-server
javadefault-jdk or openjdk-17-jdk
libssllibssl-dev
build-essentialbuild-essential (correct, but check spelling)

Development libraries on Debian/Ubuntu typically have a -dev suffix. If you are compiling software and a header file is missing, you probably need the -dev variant of the library. Similarly, if you are trying to install a command-line tool and it is not found, see Fix: python: command not found for a related scenario.

Use apt list to check if a package exists at all:

apt list --all-versions some-package 2>/dev/null

If this returns nothing, the package either does not exist in your enabled repositories or is named differently.

Fix 3: Enable Universe and Multiverse Repositories

Ubuntu organizes packages into four components:

  • main — officially supported, open-source packages
  • restricted — officially supported, proprietary drivers
  • universe — community-maintained, open-source packages
  • multiverse — community-maintained, packages with legal or licensing restrictions

By default, minimal installations or certain cloud images may only have main enabled. Many common packages live in universe, including developer tools, libraries, and utilities.

Enable universe and multiverse:

sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt-get update

If add-apt-repository is not available, install it first:

sudo apt-get install software-properties-common

You can also manually edit the sources list. On Ubuntu 22.04 and earlier, edit /etc/apt/sources.list:

sudo sed -i 's/^deb http/deb http/' /etc/apt/sources.list

Make sure lines containing universe are not commented out (no # at the start). On Ubuntu 24.04 and later, the sources configuration uses the DEB822 format in /etc/apt/sources.list.d/ubuntu.sources. Open it and ensure Components: includes main restricted universe multiverse.

On Debian, the equivalent concept is the contrib and non-free components:

# Debian 12 (bookworm) and later
sudo apt-add-repository contrib
sudo apt-add-repository non-free-firmware
sudo apt-get update

Fix 4: Fix an Outdated or Broken Sources List

If apt-get update itself produces errors or warnings, your /etc/apt/sources.list file may reference repositories that no longer exist, use wrong URLs, or have mismatched distribution codenames.

Check your current sources:

cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/

Common issues:

  1. Wrong codename. Each Ubuntu or Debian release has a codename (e.g., jammy for Ubuntu 22.04, bookworm for Debian 12). If the codename in your sources list does not match your actual release, APT will fail. Check your release:
lsb_release -cs
  1. HTTP instead of HTTPS. Some mirrors require HTTPS. Install the transport:
sudo apt-get install apt-transport-https ca-certificates
  1. Broken third-party sources. Files in /etc/apt/sources.list.d/ from PPAs or external repositories can break your entire update process if those sources go offline. Temporarily move them away to test:
sudo mkdir -p /etc/apt/sources.list.d/disabled
sudo mv /etc/apt/sources.list.d/problematic.list /etc/apt/sources.list.d/disabled/
sudo apt-get update

Fix 5: Add the Required PPA

Some packages are only available through Personal Package Archives (PPAs) or third-party repositories that are not part of the default Ubuntu/Debian configuration.

Adding a PPA:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.12

Adding a third-party repository (e.g., Docker’s official repo):

# Add Docker's GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Add the repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

After installing Docker, if you run into socket permission errors, see Fix: Docker Permission Denied While Trying to Connect to the Docker Daemon Socket.

Adding the Node.js repository (via NodeSource):

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install nodejs

Always verify that you trust a third-party repository before adding it. PPAs and external sources can push arbitrary packages to your system.

Common Mistake: Running apt-get install and apt-get update as separate RUN instructions in a Dockerfile. Docker caches each layer independently, so a cached update layer may contain a stale package index, causing installs to fail on subsequent builds.

Fix 6: Docker Minimal Images — Run apt-get update in Your Dockerfile

Official Docker base images like ubuntu, debian, and python are deliberately stripped down. They ship with no local package index to keep image sizes minimal. If you try to install packages without updating first, you will always get “Unable to locate package.”

Wrong — this will fail:

FROM ubuntu:24.04
RUN apt-get install -y curl

Correct — always update first:

FROM ubuntu:24.04
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    && rm -rf /var/lib/apt/lists/*

Key practices for Dockerfiles:

  1. Always combine apt-get update and apt-get install in the same RUN instruction. If you split them into separate RUN lines, Docker’s layer caching may use a cached (empty or stale) update layer, causing the install to fail on subsequent builds.

  2. Clean up after installing with rm -rf /var/lib/apt/lists/* to reduce image size.

  3. Use apt-get instead of apt in Dockerfiles and scripts. The apt command is designed for interactive terminal use and may produce warnings in non-interactive contexts.

  4. Set the frontend to noninteractive to prevent installation prompts from hanging the build:

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata

If you are running into disk space issues while building images, see Fix: Docker No Space Left on Device. For permission issues when running containers, see Fix: bash: Permission denied.

Fix 7: Proxy or Firewall Blocking APT

If you are behind a corporate proxy or firewall, APT may be unable to reach the repository servers. The symptoms include apt-get update hanging, timing out, or returning “Failed to fetch” errors — and as a result, the package index is never populated.

Configure APT to use a proxy:

Create or edit /etc/apt/apt.conf.d/proxy.conf:

Acquire::http::Proxy "http://proxy.example.com:8080";
Acquire::https::Proxy "http://proxy.example.com:8080";

Or set environment variables before running apt:

export http_proxy="http://proxy.example.com:8080"
export https_proxy="http://proxy.example.com:8080"
sudo -E apt-get update

The -E flag with sudo preserves your environment variables (including proxy settings) when running as root.

Test connectivity directly:

# Can you reach the repository server?
curl -I http://archive.ubuntu.com/ubuntu/dists/

# Can you resolve DNS?
nslookup archive.ubuntu.com

# Check if a specific port is reachable
nc -zv archive.ubuntu.com 80
nc -zv archive.ubuntu.com 443

In Docker behind a proxy, pass the proxy settings as build arguments:

ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN apt-get update && apt-get install -y curl

Build with:

docker build --build-arg HTTP_PROXY=http://proxy:8080 --build-arg HTTPS_PROXY=http://proxy:8080 .

Fix 8: Architecture Mismatch

If you are running on an ARM system (like a Raspberry Pi, Apple Silicon Mac with a Linux VM, or AWS Graviton instances) and trying to install a package that only exists for amd64, APT will report “Unable to locate package.”

Check your architecture:

dpkg --print-architecture

This returns amd64, arm64, armhf, or similar.

Check which architectures a package supports:

apt-cache showpkg some-package

If you need a package from a different architecture, you can add the architecture and try again (for packages that support multi-arch):

sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get install some-package:amd64

However, this only works for libraries, not executables. You cannot run an amd64 binary on arm64 hardware without emulation. For Docker users building multi-architecture images, use docker buildx with QEMU emulation:

docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 -t myimage .

If you are creating directories or files during your build and encountering permission issues, see Fix: EACCES: permission denied, mkdir.

Fix 9: End-of-Life (EOL) Ubuntu or Debian Version

When an Ubuntu or Debian release reaches end of life, its package repositories are moved from the main servers to an archive. The default URLs in /etc/apt/sources.list stop working, and apt-get update either fails entirely or returns empty package lists.

Check if your release is EOL:

lsb_release -a

Then check the official release pages:

  • Ubuntu: standard releases are supported for 9 months, LTS releases for 5 years
  • Debian: each release is supported for about 3 years, with 2 additional years of LTS

If your release is EOL, update the sources to use the archive server:

For Ubuntu:

sudo sed -i 's|archive.ubuntu.com|old-releases.ubuntu.com|g' /etc/apt/sources.list
sudo sed -i 's|security.ubuntu.com|old-releases.ubuntu.com|g' /etc/apt/sources.list
sudo apt-get update

For Debian:

sudo sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
sudo sed -i '/security.debian.org/d' /etc/apt/sources.list
sudo apt-get -o Acquire::Check-Valid-Until=false update

The -o Acquire::Check-Valid-Until=false flag is necessary because archived Debian repositories have expired Release files.

The real fix is to upgrade. Running an EOL release means you are not getting security updates. Plan a distribution upgrade:

# For Ubuntu
sudo do-release-upgrade

If you are running Docker containers based on old images, update your FROM line to a supported release. Using ubuntu:20.04 or debian:bullseye is fine as long as those versions are still in their support window, but using ubuntu:18.04 or older means you will increasingly encounter “Unable to locate package” errors as mirrors drop old releases.

Fix 10: Package Is Available via Snap, Not APT

Starting with Ubuntu 16.04 and increasingly in later releases, some packages have been moved out of the APT repositories and are only available as Snap packages. This is a deliberate decision by Canonical for certain software categories.

Common packages that may only be available as snaps:

  • chromium-browser (since Ubuntu 20.04, the APT package is just a wrapper that installs the snap)
  • firefox (since Ubuntu 22.04)
  • Various desktop applications

Check if a snap exists:

snap find some-package

Install via snap:

sudo snap install some-package

If you specifically need the APT/deb version (for example, in a server environment, a Docker container, or because snap confinement causes issues), you have options:

  1. Use a PPA that packages the software as a traditional deb. For example, the Mozilla team PPA provides Firefox as a deb package.

  2. Download the .deb file directly from the project’s website and install it manually:

sudo dpkg -i package.deb
sudo apt-get install -f  # fix any missing dependencies
  1. Use the upstream binary. Many tools (like Node.js, Go, and Rust) provide standalone binary distributions that do not require APT or snap at all.

Note that snap is not available inside Docker containers by default, and installing it there is not recommended. For containerized environments, stick with APT packages, direct binary downloads, or build from source.

Still Not Working?

GPG key errors preventing update

If apt-get update completes but shows GPG errors like NO_PUBKEY, the package index may be partially updated, causing some packages to appear missing:

# Example error
W: GPG error: http://ppa.launchpad.net/some/ppa/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABCDEF1234567890

Fix by adding the missing key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABCDEF1234567890
sudo apt-get update

On newer systems (Ubuntu 22.04+), apt-key is deprecated. Use signed-by in the source definition instead, pointing to a keyring file in /usr/share/keyrings/.

The package exists but has unmet dependencies

Sometimes apt-cache search finds the package, but apt-get install refuses with “has no installation candidate” or “depends on X but it is not going to be installed.” This is different from “Unable to locate package” but can appear alongside it:

# See why a package can't be installed
apt-cache policy some-package

# Try to fix broken dependencies
sudo apt-get install -f

# Try aptitude, which offers alternative resolution strategies
sudo apt-get install aptitude
sudo aptitude install some-package

Held or pinned packages interfering

APT pinning or held packages can prevent installation. Check for holds:

apt-mark showhold
dpkg --get-selections | grep hold

Remove a hold:

sudo apt-mark unhold some-package

Check for pinning rules that might block a package:

apt-cache policy some-package
cat /etc/apt/preferences.d/*

Virtual packages

Some package names are “virtual” — they are provided by another package but do not exist as standalone packages. For example, mail-transport-agent is a virtual package provided by postfix, exim4, and others. You cannot install a virtual package directly; you must install one of the packages that provides it:

apt-cache showpkg mail-transport-agent

This shows which real packages provide the virtual package.

Temporary server issues

Ubuntu and Debian mirror servers occasionally go down or lag behind. If you suspect a temporary mirror issue:

# Switch to the main server temporarily
sudo sed -i 's|http://[a-z]*\.archive\.ubuntu\.com|http://archive.ubuntu.com|g' /etc/apt/sources.list
sudo apt-get update

Or switch to a different regional mirror. You can also use apt-mirror or a local caching proxy like apt-cacher-ng to avoid depending on external mirrors in CI/CD environments where reliability matters.


Related: Fix: bash: Permission denied | Fix: Docker Permission Denied While Trying to Connect to the Docker Daemon Socket | Fix: Docker No Space Left on Device | Fix: EACCES: permission denied, mkdir | Fix: python: command not found

F

FixDevs

Solo developer based in Japan. Every solution is cross-referenced with official documentation and tested before publishing.

Was this article helpful?

Related Articles