Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for Linux Admins By James Joyner IV · · 8 min read Last reviewed Jul 2026

Linux Error Guide: 'E: Unable to locate package' — Fix APT Package Not Found

Quick answer

Resolve APT's 'E: Unable to locate package' on Debian and Ubuntu: run apt update, enable the universe repo, fix package name typos, and add the correct third-party sources.

  • #linux
  • #troubleshooting
  • #errors
  • #apt
Free toolkit

Stuck on this Linux Admins error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Overview

APT prints this when you ask it to install a package it cannot find in any of its known package indexes. On Debian and Ubuntu it looks like:

$ sudo apt install htop
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package htop

The message means APT searched its local cache of available packages — built from the repositories in /etc/apt/sources.list and /etc/apt/sources.list.d/ — and found no package by that name. It is almost never a claim that the software does not exist; it is a claim that this system’s current package index has no entry for that name.

Symptoms

  • apt install <name> immediately fails with E: Unable to locate package <name>.
  • apt-cache search <name> returns nothing even for well-known packages.
  • The failure appears on a freshly installed or freshly imaged host that has never run apt update.
  • A package that installs fine on one machine fails on another with a different Ubuntu release.
  • E: Unable to locate package is accompanied by E: Couldn't find any package by regex.

Common Root Causes

  • Stale or empty package indexapt update has never run, or has not run since the sources changed, so the cache lists nothing to install.
  • Disabled component — the package lives in universe or multiverse, which are not enabled by default on some Ubuntu images.
  • Package name typo or rename — the binary name differs from the package name (e.g. nc vs netcat-openbsd, pip vs python3-pip).
  • Missing third-party repository — packages like docker-ce or nodejs from NodeSource require adding the vendor’s APT source and key first.
  • Wrong distribution codename — a source pinned to an old or wrong release (focal on a jammy host) yields no matching index.
  • Failed apt update — a broken or unreachable repo caused the index build to fail, leaving the cache incomplete.

Diagnostic Workflow

Refresh the package index first — this alone resolves the majority of cases:

sudo apt update

Confirm the package actually exists in a configured repo and see its exact name:

apt-cache search <keyword>          # search descriptions and names
apt-cache policy <package>          # shows candidate version and origin, or nothing
apt list --all-versions '<glob>*'   # list matching package names

Check which repositories and components are enabled:

grep -rE '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/
lsb_release -sc                     # your distro codename (e.g. jammy, noble)

Look for errors that broke the last index update (a failing repo makes packages disappear):

sudo apt update 2>&1 | grep -iE 'err|fail|not found|404'

Example Root Cause Analysis

A user on a minimal Ubuntu 22.04 cloud image could not install htop:

$ sudo apt install htop
E: Unable to locate package htop

apt-cache policy htop returned nothing, and apt update had never been run on the fresh image, so the cache was empty. After updating, the same command still failed for a different package, python-is-python3, which lives in universe:

$ sudo apt update
$ apt-cache policy python-is-python3
N: Unable to locate package python-is-python3

Enabling the universe component and updating again resolved it:

sudo add-apt-repository universe
sudo apt update
sudo apt install htop python-is-python3

The root cause was two layered issues: a never-updated index (fixed by apt update) and a package in a disabled component (fixed by enabling universe). Both surfaced as the same generic Unable to locate package message.

Prevention Best Practices

  • Always run sudo apt update before apt install, especially on fresh images and in Dockerfiles (apt-get update && apt-get install -y).
  • Enable universe (and multiverse where licenses permit) in your base image or provisioning so common packages resolve.
  • Verify the exact package name with apt-cache search rather than assuming it matches the command name.
  • Pin sources to the correct codename from lsb_release -sc; never hardcode a release that may not match the host.
  • When adding vendor repos, add the signing key and source, then apt update before installing.
  • Treat a failing apt update as a blocker — fix the broken repo before trusting apt install results.

Quick Command Reference

sudo apt update                          # rebuild the package index (fix #1)
apt-cache search <keyword>               # find the real package name
apt-cache policy <package>               # is it available? from where?
sudo add-apt-repository universe         # enable the universe component
lsb_release -sc                          # distro codename for sources
grep -rE '^deb ' /etc/apt/sources.list.d/# list enabled repositories
apt-get install -y <pkg>                 # noninteractive install (scripts)

Conclusion

E: Unable to locate package means APT’s local index has no entry for the name you gave it — not that the software is missing from the world. Start with apt update, then confirm the exact name with apt-cache search and check that the right components (universe/multiverse) and any vendor repositories are enabled. Getting into the habit of updating the index before installing, and verifying names rather than guessing, makes this one of the fastest APT errors to clear.

Free download · 368-page PDF

Fixed it? Get 500 Linux Admins & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.