About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
E: Unable to locate package examplepkg means apt looked in its local package lists and found no package with that exact name. It does not say the package does not exist anywhere. Either the lists on this server are empty or out of date, the configured sources do not carry the component that holds the package, a source file is being ignored, or the name is not the one the distribution uses. The checks below find which, using commands that only read.
What the error means
apt installs from a local cache built from package lists. The apt-get manual says update "is used to resynchronize the package index files from their sources", and that an update should always be performed before an upgrade. The sources are the files in /etc/apt/sources.list and /etc/apt/sources.list.d/, which the sources.list manual says apt reads for "any number of active sources".
Reading the code, the message is raised by canNotFindPkgName in apt-pkg/cacheset.cc (tag 2.6.1), which reports Unable to locate package with the name you typed when no package in the cache has that name. The apt-cache manual says apt-cache works from the metadata and "independently of the availability of the configured sources (e.g. offline)". So a successful network connection does not matter here: the question is what is in the lists on disk.
Several facts from the manuals narrow the causes:
- A
debline has the formdeb uri suite component1 component2. The sources.list manual says the Debian components are "main, contrib, non-free or non-free-firmware". A package in a component you did not list is not in your lists. - Files in
/etc/apt/sources.list.d/need the extension.listor.sourcesand may only contain letters, digits, underscore, hyphen and period in the file name. The manual says otherwise "APT will print a notice that it has ignored a file". - A source can restrict architectures with the
Architecturesoption.apt-cache madisonshows information only for the architecture apt has retrieved lists for (APT::Architecture). - Lists live under
/var/lib/apt/lists/by default (the apt-get manual lists that directory asDir::State::Lists).
If the problem is an apt-get update failure instead, see apt: The repository no longer has a Release file (or does not have one) and apt NO_PUBKEY: "The following signatures couldn't be verified because the public key is not available".
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The package lists were never downloaded, for example on a fresh image or container | The error for common packages too | ls /var/lib/apt/lists/ has no package list files; apt-cache policy shows no sources |
| The package sits in a component that is not enabled | The name is right and other packages install | apt-cache policy lists your sources with only main; the distribution's package search shows the package in another component |
| The source file is ignored | A notice about an ignored file during apt-get update; the source is missing from apt-cache policy |
The file name in /etc/apt/sources.list.d/ does not end in .list or .sources, or has other characters |
| The name is misspelled or is not the package name | Other packages install | apt-cache search --names-only with part of the name shows the real name |
| The suite no longer carries the package, or no longer exists | apt-get update errors about Release files or packages missing from the suite |
The apt-get update output names the suite; apt-cache madison shows no version |
| The architecture is restricted or not served | The package exists for another architecture | dpkg --print-architecture and the Architectures setting of the source |
Prove the cause before changing anything
All of these only read.
1. Show the sources apt actually uses.
apt-cache policy
The manual says that with no arguments it "will print out the priorities of each source". A good result lists each repository you expect, with its suite and component. A bad result is an empty or short list.
2. Read the source files.
grep -Rn -v '^[[:space:]]*#' /etc/apt/sources.list /etc/apt/sources.list.d/
This prints every line that is not a comment, with its file name. Check the deb or Types: lines, the suite, and that every component you need is on the line (Components: in the .sources format). Compare the suite with the release the server runs.
3. Check the list directory.
ls -l /var/lib/apt/lists/
An empty directory, or one holding only the partial sub-directory, means no lists have been downloaded.
4. Search for the name.
apt-cache search --names-only examplepkg
apt-cache madison examplepkg
The manual says --names-only limits the search to the package name and the packages it provides. madison shows the available versions. No output from both means the lists you have do not contain the name.
5. Check the architecture.
dpkg --print-architecture
The dpkg manual refers to this as the architecture dpkg is built for.
Fix
Download the package lists
First save the current lists, so you can compare or copy them back:
cp -a /var/lib/apt/lists /root/apt-lists-before.2026-12-01
Risk: the next command downloads index files from every configured source and replaces the local copies. A source that fails leaves its lists missing until the next successful update.
Run it as root. The manual says update fetches the indexes from the locations in sources.list:
apt-get update
To back out, copy the saved lists over the new ones. Files that did not exist in the saved copy stay in place. Do not run apt-get update afterwards as part of the back-out: any later update downloads the current lists again and replaces the saved ones, so the saved lists stay in place only until the next update:
ls -l /root/apt-lists-before.2026-12-01
cp -a /root/apt-lists-before.2026-12-01/. /var/lib/apt/lists/
Read the apt-get update output for errors before you try the install again.
Add the missing component
First save the file that holds the line. The name is an example; use the file that grep showed:
cp -p /etc/apt/sources.list /etc/apt/sources.list.2026-12-01
Risk: the next edit adds a component to a source, which makes every package in it, including its updates, available to apt-get upgrade on this server. Some components carry non-free software with its own licence terms, so check that the licence suits the server before enabling it.
Edit the line to the form the manual shows, adding only the component the package needs. For a package in non-free, the line becomes:
deb http://deb.debian.org/debian bookworm main non-free
Then run the update step above, including its save step and its Risk paragraph, which apply here too.
To undo it, restore the saved file under its original name and update again:
ls -l /etc/apt/sources.list.2026-12-01
cp -p /etc/apt/sources.list.2026-12-01 /etc/apt/sources.list
apt-get update
Rename a source file that apt ignores
First save a listing of the folder:
ls -l /etc/apt/sources.list.d/ > /root/sources-list-d-before.2026-12-01.txt
Risk: the next command renames a source file, so apt starts using the sources inside it on the next update.
Rename it so it ends in .list (one-line format) or .sources (deb822 format), using only letters, digits, underscore, hyphen and period. The names here are examples:
mv /etc/apt/sources.list.d/example-repo.save /etc/apt/sources.list.d/example-repo.list
To back out, rename it back and update:
mv /etc/apt/sources.list.d/example-repo.list /etc/apt/sources.list.d/example-repo.save
apt-get update
Correct the name
If apt-cache search --names-only shows a different name, use that name. No file changes.
Example (illustrative): On web01, apt-get install examplepkg fails with E: Unable to locate package examplepkg. apt-cache policy lists only the main component of bookworm. The sources line is deb http://deb.debian.org/debian bookworm main. The distribution's package page puts examplepkg in non-free. The engineer saves /etc/apt/sources.list, adds non-free after main, runs apt-get update, and apt-cache madison examplepkg now prints a version.
Confirm the fix
apt-get updatefinishes without errors for the source you changed.apt-cache policy examplepkgshows a candidate version and the source it comes from.apt-cache madison examplepkglists at least one version.- The install command now runs. Read the list of packages it proposes before you accept it.
What to watch afterwards
- Keep
apt-get updatein your patching routine so the lists do not go stale. - After adding a component, watch what
apt-get upgradeproposes in the next maintenance window. - On a server that moved to a newer release, confirm that the suite name in every source file matches.
Read next
Related articles you may want next.
- Troubleshootingapt: The repository no longer has a Release file (or does not have one)apt update says the repository no longer has a Release file? Read the URL and suite in the message, check them, then correct or disable the source.Read article
- Troubleshootingapt NO_PUBKEY: "The following signatures couldn't be verified because the public key is not available"apt update shows NO_PUBKEY or signatures couldn't be verified? Find the missing key ID, fetch the vendor key safely and use Signed-By, not apt-key.Read article
- Troubleshooting"Could not get lock /var/lib/dpkg/lock-frontend": find the process holding itapt says Could not get lock /var/lib/dpkg/lock-frontend? Find the process holding it, wait for unattended upgrades and never delete the lock file.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The component names above are the Debian ones. Ubuntu and other derivatives name their components and suites differently; read your distribution's own documentation.
apt-cache policyandapt-cache madisondescribe what is in the local lists. They cannot tell you what the remote archive holds today.- Third-party repositories can add components and packages with no relation to the distribution; their documentation governs them.
Sources
- apt-get(8) — Debian Manpages, bookworm (apt 2.6.1), source updated 2023-05-25, accessed 1 December 2026
- apt-cache(8) — Debian Manpages, bookworm (apt 2.6.1), source updated 2023-05-25, accessed 1 December 2026
- apt(8) — Debian Manpages, bookworm (apt 2.6.1), source updated 2023-05-25, accessed 1 December 2026
- sources.list(5) — Debian Manpages, bookworm (apt 2.6.1), source updated 2023-05-25, accessed 1 December 2026
- dpkg(1) — Debian Manpages, bookworm (dpkg 1.21.22), source updated 2023-05-11, accessed 1 December 2026
- apt-pkg/cacheset.cc (tag 2.6.1) — apt source at tag 2.6.1, Debian apt repository mirror on GitHub, no date shown, accessed 1 December 2026
This article was originally published on .