This error occurs when the apt package manager cannot find a package in your configured repositories. The package may have a typo, your package cache may be outdated, or required repositories may be disabled on your system.
The "E: Unable to locate package" error means that apt (Advanced Package Tool) cannot find the package you're trying to install in any of its configured repositories. This is one of the most common errors when installing software on Debian-based systems like Ubuntu, Debian, or Linux Mint. When you run `apt install package-name`, apt searches through its local package cache, which contains a database of all available packages from your configured repositories. If the package doesn't appear in this cache, apt reports it cannot be located. The root cause is usually one of four things: a typo in the package name, an outdated package cache that hasn't been synced with repositories, disabled repositories that contain the package, or the package genuinely not being available for your system.
Before trying to install anything, refresh apt's local package cache:
sudo apt updateThis command connects to your configured repositories and downloads the latest list of available packages. If you just installed Ubuntu or haven't run apt update in a while, this is usually the solution.
Important: You must use apt update (not apt upgrade). These are different:
- apt update - Downloads the latest package list from repos
- apt upgrade - Installs available updates for already-installed packages
After updating, try your installation again:
sudo apt install package-nameDouble-check the package name for typos. Linux is case-sensitive, so "Python" and "python" are different.
Search for the correct package name:
apt search package-nameThis will list all packages matching your search term. For example:
# Wrong: trying to install 'docker'
$ apt search docker
# Shows: docker.io, docker-compose, etc.
# Correct:
sudo apt install docker.ioCommon package name surprises:
- docker is actually docker.io on Ubuntu
- vscode is code when installed from apt
- nodejs is available as nodejs (with different versions like nodejs-14, nodejs-16)
Use apt search liberally to find the exact name.
View your configured repositories to ensure they're correct:
cat /etc/apt/sources.listAlso check sources in the sources.list.d directory:
ls /etc/apt/sources.list.d/
cat /etc/apt/sources.list.d/*.listIf you see many lines starting with #, they are disabled/commented out. For example:
# deb http://archive.ubuntu.com/ubuntu focal main restrictedThe # at the beginning disables this repository. Common reasons for disabled repos:
- System installer disabled them
- Old PPA (Personal Package Archive) that no longer exists
- Intentionally disabled repositories
Caution: Only edit if you know what you're doing. Broken repositories can cause other problems. A safer approach is to use:
sudo add-apt-repository universe
sudo apt updateSome packages live in additional repositories that may not be enabled by default. Enable them with:
# Enable Universe (community-maintained open source)
sudo add-apt-repository universe
# Enable Multiverse (restricted, proprietary software)
sudo add-apt-repository multiverse
# Refresh the package cache
sudo apt updateThen try installing again:
sudo apt install package-nameNote: Recent Ubuntu versions (20.04+) usually have these pre-enabled. This matters more on older versions or fresh minimal installs.
Not all packages are available for every Ubuntu or Debian release. Check online or use a web tool:
Visit [Ubuntu Packages](https://packages.ubuntu.com/) or [Debian Packages](https://www.debian.org/distrib/packages) and search your package name.
First, identify your Ubuntu/Debian version:
lsb_release -a
# or
cat /etc/os-releaseExample output: Ubuntu 22.04 LTS (Jammy Jellyfish)
Then check the package site to see which versions have your package. If your version isn't listed, the package simply isn't available for you.
Workaround 1: Install from a newer/older version manually:
# Add PPA for newer version (example: Python 3.11)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11Workaround 2: Upgrade your OS to a newer version that has the package.
Workaround 3: Build from source if the package source is available.
If you're running an end-of-life (EOL) Ubuntu or Debian version, repositories may have been archived and are no longer actively updated.
Check your Ubuntu version:
lsb_release -aCompare against [Ubuntu Release Cycle](https://wiki.ubuntu.com/Releases). Once a version reaches EOL, security updates stop and packages may be hard to find.
Solution: Upgrade to a supported LTS (Long Term Support) version:
# Check if upgrade is available
sudo do-release-upgrade -c
# Perform the upgrade (if available)
sudo do-release-upgradeLTS versions are stable and supported longer:
- Ubuntu 20.04 LTS - Supported until April 2030
- Ubuntu 22.04 LTS - Supported until April 2032
If apt doesn't have the package, try Snap or Flatpak:
Using Snap (usually pre-installed on Ubuntu):
snap install package-nameUsing Flatpak (requires installation first):
sudo apt install flatpak
flatpak install flathub package-nameFrom source (if source code is available):
git clone https://github.com/user/repo.git
cd repo
./configure
make
sudo make installFrom official website: Many projects (Docker, VSCode, etc.) provide .deb files directly on their download pages.
Understanding APT's package database: When you run apt update, your system downloads Packages files from each repository's Release subdirectory and caches them locally in /var/lib/apt/lists/. If these files are corrupted, apt may not see packages correctly. You can force a clean rebuild:
sudo rm -rf /var/lib/apt/lists/*
sudo apt updateRepository GPG keys: Some PPAs require you to import their GPG keys before they work:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID
# or for newer systems:
curl -fsSL https://example.com/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/example.gpgChecking package details: Learn more about a package before installing:
apt show package-name # Show package details
apt depends package-name # Show dependencies
apt rdepends package-name # Show reverse dependencies (what depends on this)PPA issues: Personal Package Archives (PPAs) can be problematic if:
- The PPA is archived or no longer maintained
- The maintainer stopped building for your Ubuntu version
- The PPA causes conflicts with official packages
List your PPAs:
sudo add-apt-repository --listRemove a problematic PPA:
sudo add-apt-repository --remove ppa:user/ppa-namePartial upgrades and held packages: If you've held or downgraded a package, apt may have dependency issues:
sudo apt --fix-broken install
sudo apt autoremoveDocker-specific note: Docker is a special case where the official package on Ubuntu is docker.io (not docker). This is due to legacy trademark/naming issues. Always use:
sudo apt install docker.ioE: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT