Fix "Unable to Locate Package" Error on Ubuntu

Quick answer: E: Unable to locate package is a metadata error, not a network error. APT searches a local package index — not the internet — when you run apt install. Run sudo apt update to refresh that index. If the error persists, you're likely missing the Universe repository, have a typo in the package name, or you're on an end-of-life Ubuntu version.

What APT is actually doing (and why this error appears)

When you run sudo apt install something, APT doesn't reach out to the internet directly. It queries a local package index stored in /var/lib/apt/lists/ — a snapshot of what your configured repositories currently offer. If that snapshot is stale, incomplete, or if the repo containing your package isn't enabled, APT has no record of the package and throws the error.

That distinction matters because it changes where you look for the fix. You're not debugging a connection; you're fixing the metadata.

Fix 1: Run sudo apt update first — always

This resolves the error the majority of the time. Fresh Ubuntu installs, cloud instances, WSL imports, and Docker base images often haven't had apt update run, so the local cache is empty or stale by days or weeks.

sudo apt update
sudo apt install <package-name>

You'll see APT pull current package lists from your configured mirrors. After it completes, retry the install. I've watched people spend an hour tracing alleged network issues when a single apt update would have fixed it immediately.

Fix 2: Check the exact package name

APT is case-sensitive. sudo apt install VLC fails; sudo apt install vlc works. Package names also use hyphens and underscores in places that don't always match what a website calls the software: net-tools, python3-pip, build-essential.

If you're unsure of the exact name, search for it:

apt search <keyword>

That searches both package names and descriptions, which returns a lot of noise. To narrow it to package names only:

apt-cache search --names-only <keyword>

Once you have a candidate, confirm it's actually in your cache and see which repo it comes from:

apt-cache policy <package-name>

If Candidate: shows a version number, the package is available and you can install it. If you see Candidate: (none), it's not in your local cache at all — move to the next fixes.

Fix 3: Enable the Universe or Multiverse repository

Ubuntu splits its archive into four components. Understanding which is which saves a lot of confusion:

  • main — officially supported, open-source software. Always enabled by default.
  • restricted — proprietary hardware drivers (NVIDIA, Wi-Fi firmware). Enabled by default on desktop installs.
  • universe — community-maintained free and open-source software. Not always enabled on minimal, server, or cloud installs.
  • multiverse — software with licensing or legal restrictions, such as unrar or steam-installer. Disabled by default.

Universe is the one that trips people up most often. It contains a huge amount of common tooling: ffmpeg, neovim, htop, tree, python3-pip, git-extras, and thousands more. Minimal server images, Docker base images, and WSL imports frequently ship without it.

Check what's currently enabled on your system (Ubuntu 22.04 and older):

grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null

On Ubuntu 24.04 and newer, sources use the DEB822 format stored in /etc/apt/sources.list.d/ubuntu.sources — check that file as well.

To enable Universe and Multiverse:

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

The command will prompt you to press Enter to confirm. If add-apt-repository isn't found (common on minimal and Docker installs), install it first:

sudo apt install software-properties-common

Fix 4: Verify the package exists for your specific Ubuntu version

Not every package is available in every Ubuntu release. Some packages were added in newer versions; others have been renamed or dropped. Check your current version:

lsb_release -a

Then look the package up at packages.ubuntu.com. Select your release codename (for example, jammy for 22.04 or noble for 24.04) and search by package name. The site shows exactly which component the package is in and whether it exists for your release at all. This is the fastest way to rule out a version mismatch before you start adding PPAs.

Fix 5: You're running an end-of-life Ubuntu version

This one catches people who set up a server and haven't touched it in a while. Once an Ubuntu release hits end of standard support, Canonical stops updating the main archive. The apt update command still completes without errors, but the package lists are frozen — new packages aren't there, and some mirrors for EOL releases stop responding.

Version Codename Standard EOL
20.04 LTSFocal FossaApril 2025
22.04 LTSJammy JellyfishApril 2027
24.04 LTSNoble NumbatApril 2029
26.04 LTSResolute RaccoonApril 2031

If you're on Ubuntu 20.04, standard support ended in April 2025. Your realistic options: upgrade to a supported LTS, subscribe to Ubuntu Pro for Expanded Security Maintenance (ESM is free for personal use on up to 5 machines and extends coverage by 5 years), or — my recommendation for any production server — rebuild on a current LTS. Running production workloads on an EOL OS creates security debt faster than you'll address it.

The official release cycle and support dates are at ubuntu.com/about/release-cycle.

Fix 6: The package isn't in Ubuntu's repos at all

Some software simply isn't packaged by Ubuntu or Debian. For those cases, you have a few paths.

PPAs (Personal Package Archives)

Launchpad-hosted repos maintained by developers or projects — common for getting newer versions of tools or software Ubuntu doesn't ship. Add one with:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Only add PPAs from sources you actually trust. There is no vetting process — anyone can publish to Launchpad, and a malicious PPA has full access to your system during package installation.

Direct .deb install

Many vendors — VSCode, Google Chrome, Slack, and others — provide official .deb files directly. Download and install with:

sudo dpkg -i package.deb
sudo apt install -f

That second command tells APT to resolve and install any missing dependencies. Don't skip it — dpkg alone won't pull deps and you'll end up with a broken install.

Snap

Some packages are available as Snaps even when they're not in the apt archive. Snaps are isolated from the rest of the system, which helps with cross-version compatibility but comes with tradeoffs: slower startup times, confinement quirks, and larger disk footprint. For desktop apps and developer tools, they're often good enough.

snap find <package-name>
sudo snap install <package-name>

Quick reference: cause and fix at a glance

Situation Root Cause Fix
Fresh install or Docker image Empty or stale apt cache sudo apt update
Package exists online, not found by apt Typo in name, or Universe disabled apt search <name>, enable Universe
Correct name, still fails after update Universe or Multiverse repo missing sudo add-apt-repository universe
Works on 24.04, fails on 22.04 Package not available in older release Use PPA, or .deb from vendor
Nothing works, old server EOL Ubuntu version Upgrade LTS or enable Ubuntu Pro ESM

Frequently asked questions

Why does apt-get install say "unable to locate package" when I can find the software online?

The package exists somewhere on the internet but isn't in your local apt cache. Run sudo apt update first to refresh the cache. If it still fails, the package is likely in the Universe repository — disabled by default on server and minimal installs. Enable it with sudo add-apt-repository universe && sudo apt update, then retry.

Should I use apt or apt-get?

Either works. apt is the recommended command for interactive terminal use — it has progress bars and cleaner output. apt-get is preferred in shell scripts because its output format is stable across versions. For troubleshooting this error, they're interchangeable.

What's the difference between apt update and apt upgrade?

apt update refreshes the local package index from your repositories — nothing is installed or changed on your system. apt upgrade installs available updates for packages already installed. To fix the "unable to locate package" error, you need apt update. Running apt upgrade instead won't help.

Is it safe to enable the Universe repository?

For most purposes, yes. Universe contains legitimate community-maintained free and open-source software. The real caveat is that security patches aren't as timely as they are for packages in main — Ubuntu Pro's Expanded Security Maintenance extends coverage to Universe packages, but on a standard install you're relying on the community timeline. That's worth factoring in for internet-facing production servers; it's a non-issue for most workstations and internal tools.

Can I mix packages from different Ubuntu releases to get one that's missing?

Don't. Mixing packages from different release codenames causes dependency conflicts and can leave your system in an unresolvable broken state. If the package you need isn't available in your current Ubuntu release, use a PPA, install from a vendor-provided .deb, or consider whether the actual solution is to upgrade to a newer Ubuntu LTS.