What the "Package not found" Error Means
The "Package not found" error (or its variants: E: Unable to locate package, No package <name> available., Error: Nothing provides <name>) is a message from your Linux distribution's package manager. It means the system did not detect the package you requested in any of the active and configured repositories.
The error appears when running installation commands such as:
sudo apt install nginx
sudo yum install httpd
sudo pacman -S vim
The system checks the local metadata cache (lists of available packages) and, if the specified name is not found, aborts the operation.
Causes
The error occurs not due to network or disk problems, but because of a mismatch between your request and the configuration of package sources. The main causes:
- Typo in the package name. The most common cause. Package names are case-sensitive and require exact spelling (e.g.,
postgresqlvspostgresql-client). - Outdated local cache. The system has not updated the list of available packages since the last installation. New packages in the repositories are unknown to it.
- Deactivated or missing repository. The package exists but is in a repository that is either not added to the configuration (
sources.list) or is added but commented out (disabled). - Package removed from repositories. The package is outdated, has been replaced, or moved to an archive (e.g.,
oldlibsin Debian). - Repository GPG key problem. An invalid or missing security key can cause the package manager to ignore the entire repository.
- Architecture mismatch. The package is built for a different architecture (e.g.,
i386), and onlyamd64is enabled on your system. - Using an outdated package manager. For example, trying to install a package from the EPEL repository in CentOS 8, which switched to
dnfand requires separate configuration.
💡 Tip: Before looking for complex causes, always first perform a cache update (
sudo apt updateand equivalents). This solves up to 50% of such problems.
Solutions
Method 1: Update Package Cache and Check Name
This is the basic and most effective diagnosis.
- Update metadata. Run the update command for your package manager.
- Debian/Ubuntu (apt):
sudo apt update - RHEL/CentOS 7 (yum):
sudo yum makecache - RHEL/CentOS 8+/Fedora (dnf):
sudo dnf makecache - Arch Linux (pacman):
sudo pacman -Sy
Pay attention to the command output. If you see errors like "Failed to fetch" or "Cannot retrieve repository metadata", there is a network connectivity or repository access problem. - Debian/Ubuntu (apt):
- Search for the package by part of its name. Ensure the package name is entered correctly.
apt search nginx # For apt yum search nginx # For yum/dnf pacman -Ss nginx # For pacman
The search results will show the exact package name and a brief description. - Try installing again.
sudo apt install nginx
Method 2: Check and Configure Repositories
If the cache update succeeded but the package is still not found, the issue is in the repository configuration.
- Find the configuration files.
- apt (Debian/Ubuntu): The main file is
/etc/apt/sources.list. Also check the/etc/apt/sources.list.d/directory for separate.listfiles. - yum/dnf (RHEL/CentOS/Fedora): The directory
/etc/yum.repos.d/. Files with the.repoextension. - pacman (Arch): The main file is
/etc/pacman.conf. Also check/etc/pacman.d/mirrorlistfor up-to-date mirrors.
- apt (Debian/Ubuntu): The main file is
- Ensure the needed repository is active. Open the file in a text editor (e.g.,
sudo nano /etc/apt/sources.list). Lines starting with#are commented out (inactive). Ensure the line with the repository containing your package does not have a#at the beginning.
Example for Ubuntu (theuniverserepository should be uncommented):# deb http://archive.ubuntu.com/ubuntu/ jammy universe deb http://archive.ubuntu.com/ubuntu/ jammy universe restricted main multiverse - For RHEL/CentOS/Fedora: Ensure in the
.repofile, under the[repo_name]section,enabled=1is set. Ifenabled=0, the repository is disabled. - After making changes, run
sudo apt update(or its equivalent) again and try the installation.
Method 3: Add the Missing Repository Manually
If you discovered the package is in a repository not present in your system (e.g., universe in Ubuntu, epel in CentOS), you need to add it.
- Ubuntu/Debian (adding universe/multiverse):
sudo add-apt-repository universe sudo add-apt-repository multiverse sudo apt update⚠️ Important: The
add-apt-repositorycommand may be missing. Install it:sudo apt install software-properties-common. - CentOS 7 (adding EPEL):
sudo yum install epel-release sudo yum update - CentOS 8+/Rocky/AlmaLinux (adding EPEL):
sudo dnf install epel-release sudo dnf update - Fedora: Most repositories are active by default. For RPM Fusion (multimedia/non-free software):
sudo dnf install rpmfusion-free-release rpmfusion-nonfree-release sudo dnf update - Arch Linux: Ensure the
[core],[extra], and[community]repositories are uncommented in/etc/pacman.conf. For AUR (unofficial packages), you will need to useyayorparu.
Method 4: Check and Install GPG Keys
If during apt update you see errors like The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <KEYID>, the package manager does not trust the repository.
- Import the missing key. Replace
<KEYID>with the long hex identifier from the error.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEYID>
Foryum/dnf, keys are usually located in/etc/pki/rpm-gpg/. They can be imported like this:sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-* - Update the cache again.
sudo apt update. The key errors should disappear.
Method 5: Install the Package Manually (Temporary Workaround)
If you need the package urgently and don't have time to configure a repository, you can download a .deb or .rpm file manually and install it. This is not recommended for system packages due to the lack of automatic updates and dependency resolution.
- Debian/Ubuntu (.deb):
# Download the file from the official website or repository wget http://ftp.us.debian.org/debian/pool/main/c/curl/curl_7.88.1-10_amd64.deb # Install it sudo dpkg -i curl_7.88.1-10_amd64.deb # If there are unresolved dependencies, run sudo apt --fix-broken install - RHEL/CentOS/Fedora (.rpm):
wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/38/Everything/x86_64/os/Packages/c/curl-7.88.1-10.fc38.x86_64.rpm sudo rpm -i curl-7.88.1-10.fc38.x86_64.rpm # For automatic dependency resolution, use yum/dnf instead sudo yum localinstall curl-*.rpm # or sudo dnf install ./curl-*.rpm
Prevention
To avoid the "Package not found" error in the future:
- Regularly update your package cache. Add
sudo apt update(or its equivalent) to your regular system update script. - Search for a package before installing. Use
apt search,yum search, orpacman -Ssto verify the exact name and availability. - Do not disable standard repositories. The system base (
main,core,extra) should always be active. Only disable unnecessary partner or third-party repositories. - When adding third-party repositories (PPA, RPM Fusion), always import their GPG keys. This ensures your system will trust them.
- Use stable distributions. Rolling-release distributions (Arch) may temporarily lack a package due to building. In stable ones (Ubuntu LTS, Debian Stable), the package set is predictable.
- Check the architecture. If you are using a 64-bit system (
amd64/x86_64), ensure you are searching for packages for that architecture. Some older packages may only be available fori386.