apt: "Unable to locate package" — Sources, Spelling, or Release

apt can't find the package in any configured repository. Ninety percent of cases are: stale indexes, the package lives in universe/multiverse (not enabled), or a typo.

What you'll see

Root causes

Package index stale or never updated

apt update refreshes the lists; on fresh systems the cache may be empty/minimal. Always the first command: sudo apt update.

Package is in universe/multiverse (not enabled) or a different release

Some packages live in non-main components; on minimal images those repos may be off. apt policy / apt-cache policy <name> shows candidate versions; check the package exists for YOUR release.

Typo or upstream rename

apt search <part> finds real names (e.g. php-xml vs php7.4-xml across releases).

Fix it

  1. Refresh indexes
    sudo apt update && sudo apt install <pkg>
  2. Search the real package name
    apt search <partial-name> 2>/dev/null | head ; apt-cache policy <pkg>
  3. Enable the missing component if needed
    sudo add-apt-repository universe && sudo apt update   # then retry the install
  4. Containers/minimal images: check sources.list exists at all
    cat /etc/apt/sources.list 2>/dev/null | grep -v '^#' | head ; ls /etc/apt/sources.list.d/

Field note

Ubuntu package availability differs by release — a package existing for 22.04 doesn't guarantee 24.04 (and vice versa). packages.ubuntu.com is the source of truth. Debian: similar trap with main vs contrib/non-free-firmware components.

Common questions

apt update ran and still can't find it. Now what?

Check the package exists for your exact release (packages.ubuntu.com / packages.debian.org), including the component (universe/contrib). If it's genuinely absent, use the upstream repo, backports, or a container image that ships it.

Is adding third-party PPAs/repos the right fix?

Prefer official sources; PPAs carry both trust and lifecycle costs. If you must, pin them explicitly and keep the least scope (single repo, signed).

Ship it right the first time

Our most-documented failures, packaged as ready-to-ship starter kits: Docker, Kubernetes, and Terraform.

Browse the template store →

One-time. Yours to modify. Instant download from the NinjaOps template store.