The "Version was not found" error occurs when you try to install a specific version of a package that is not available in any of your configured repositories. This happens because the exact version string does not match available versions, the version is too old or new, or the package is no longer maintained in your repositories.
This error appears when you use apt-get install with a specific version number (using the syntax `package=version`) but that exact version cannot be found in any of your configured repositories. The apt package manager searches through all enabled repositories for the specified version, and if it cannot locate it, the installation fails. This differs from the "Unable to locate package" error—the package exists, but the specific version you requested does not. Version format mismatches are common: the version string must match exactly what apt lists in its cache, including release names, epoch numbers, and build designations.
First, check what versions are actually available in your repositories using apt-cache:
apt-cache policy package-nameThis command shows all available versions with their sources. For example, if you run this for Docker:
apt-cache policy docker-ceYou will see output like:
docker-ce:
Installed: (none)
Candidate: 5:24.0.6~3-0~ubuntu-focal
Version table:
5:24.0.6~3-0~ubuntu-focal 500
500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
5:24.0.5~3-0~ubuntu-focal 500
500 https://download.docker.com/linux/ubuntu focal/stable amd64 PackagesNotice the exact format including colons, tildes, and build numbers.
The version you install must match exactly what appears in the apt-cache output. Do not simplify or abbreviate the version number. For example:
Incorrect (will fail):
sudo apt install docker-ce=18.03.0.ceCorrect:
sudo apt install docker-ce=5:18.03.0~ce-0~ubuntuNote the differences:
- Colons (epoch): 5:
- Tildes instead of dots: ~ce instead of .ce
- Build designation: -0~ubuntu
Always copy the complete version string from apt-cache policy output.
If you cannot find the version you need, your package cache may be outdated. Update it:
sudo apt updateThis command refreshes your local cache of available packages from all enabled repositories. Sometimes newly released versions or older versions are added back to repositories, and you need to update to see them.
Some versions may only be available for specific Ubuntu/Debian versions. Check your current distribution:
lsb_release -aOr more concisely:
lsb_release -csWhen searching for packages online (e.g., at packages.ubuntu.com), make sure you select the correct distribution version. A version available for Ubuntu 20.04 (Focal) may not be available for Ubuntu 22.04 (Jammy).
If the version you need is from a PPA or third-party repository that you removed or disabled:
sudo add-apt-repository ppa:owner/ppa-name
sudo apt update
apt-cache policy package-nameThen install using the exact version from the new apt-cache output:
sudo apt install package-name=x.x.xYou can also check what PPAs are enabled:
add-apt-repository --list | grep ppaOnce you have confirmed the exact version string from apt-cache policy, install it:
sudo apt install package-name=exact.version.stringFor example:
sudo apt install nginx=1.18.0-6ubuntu14.4The installation should succeed if the version string is exact. If it still fails, double-check the version string character-by-character against the apt-cache output.
The version string format in Debian/Ubuntu follows the format [epoch:]upstream-version[-debian-revision]. The epoch (colon-prefixed number) is used when the upstream version numbering scheme changes. Tildes (~) have special meaning in version comparison—they sort earlier than the character they precede, so 1.0~rc1 sorts before 1.0. Some packages use epoch numbers extensively (like Docker with 5: prefix) to ensure proper version ordering. If you need a very old version no longer in main repositories, check Ubuntu security archives: http://security.ubuntu.com/ or http://archive.ubuntu.com/. You can also pin specific versions using /etc/apt/preferences to prevent automatic upgrades: sudo nano /etc/apt/preferences and add entries specifying package pins.
E: 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