Run apt update First
apt installs from package lists stored on the server. A freshly created server image often has empty or old lists, so the first install fails:
sudo apt install nginx
E: Unable to locate package nginx
Download the current lists, then try again:
sudo apt update
sudo apt install nginx
Read the output of apt update: errors there, such as a repository that cannot be reached or a missing signing key, mean the lists are still incomplete. See sudo apt update for what each line means. If apt reports that the lock is held, another update is running; see could not get lock.
Check the Spelling
Package names are lowercase and exact. Search for the right one:
apt search redis
apt-cache policy redis-server
apt-cache policy shows whether a package exists in your lists and which repository offers it. The program name and the package name are not always the same: the dig command, for example, comes from a package with another name, which apt search finds.
Enable Universe on Ubuntu
Ubuntu splits its archive into components. main holds the packages Ubuntu supports directly; many common tools are in universe, which a minimal image may not have enabled. Turn it on and update:
sudo add-apt-repository universe
sudo apt update
If add-apt-repository itself is missing, see add-apt-repository: command not found. On Debian, packages outside main are in contrib, non-free, and non-free-firmware.
The Package Was Renamed or Dropped
Packages change between releases. A guide written for an older release may use a name that no longer exists:
- Version in the name: packages such as
php8.1-fpmexist only on the release that ships that version. Use the unversioned name, such asphp-fpm, or the version your release has. - Python 2 names:
pythonandpython-pipare gone; usepython3andpython3-pip. - Replaced software: Debian ships MariaDB rather than MySQL, so
mysql-serveris not in Debian's own archive;default-mysql-serverinstalls MariaDB.
Check which release you run with how to check the Ubuntu version, then search for the package name in that release.
Wrong Architecture
Some packages from outside repositories are built only for x86_64. On an ARM64 server they do not appear in the lists at all. Check your architecture:
dpkg --print-architecture
The output is amd64 or arm64. If the vendor offers no ARM64 build, the package cannot be installed on that server.
Check Your Sources Files
On Ubuntu 24.04 and later, the repositories are defined in deb822 format in /etc/apt/sources.list.d/ubuntu.sources, and /etc/apt/sources.list is empty apart from a comment. Look at the Components: line:
cat /etc/apt/sources.list.d/ubuntu.sources
It should list main restricted universe multiverse for normal use. On Debian 12 and 13, depending on how the server was installed, the sources are either one-line entries in /etc/apt/sources.list or a deb822 file, /etc/apt/sources.list.d/debian.sources, so look in both places. Debian 13 recommends the deb822 format, and sudo apt modernize-sources converts the old one. Every Suites: or release name must match your release; a leftover entry for another release causes errors or mixed packages.
An End-of-Life Release
When a release reaches its end of life, its repositories are moved to an archive server and apt update starts failing, so nothing can be found. Pointing apt at the archive only buys time without security updates. Upgrade to a supported release or reinstall on a current one.
Adding a Third-Party Repository
Some software, such as newer versions of Docker or Node.js, is published in the vendor's own repository. Adding it means trusting that vendor's signing key and letting its packages install with root rights and replace system packages. Do it only for a vendor you trust, follow the vendor's instructions, and prefer the distribution's package where it is good enough. A single downloaded package can also be installed as described in how to install .deb files. On AlmaLinux and Rocky Linux, dnf reports the same problem as "No match for argument" followed by "Unable to find a match"; many extra packages come from EPEL there. See dnf vs yum.