In this article, we will look to solve Package "package_name" has no installation candidate error on Debian based servers. Last night when I was trying to install Openssh Server packages in my freshly built Debian 11 server, then I noticed "package 'openssh-server' has no installation candidate" error which was stopping me to install any new packages. This is a very common error in a freshly built Debian based systems so I thought to write an article about this so that it will help you guys as well. So without any further delay let's dive in directly and see what can be done to solve this error.
Solved: Package "package_name" has no installation candidate in Debian
I was getting the
Package 'openssh-server' has no installation candidate error when I was trying to install
openssh-server package in my freshly built
Debian 11 System using
apt-get install openssh-server command as you can see below. More about apt-get command.
While this error can come due to multiple issues so to understand the root cause of the error we need to go step by step. To resolve this issue, first thing that you need to check is the repository list in your Debian System. You can check this easily by running
cat /etc/apt/sources.list command as you can see below.
Since in my case it is not added so I will ahead and add first by opening this file using my favorite nano editor. I will just run nano /etc/apt/sources.list command to open the file. Then I will add below repository source at the beginning of the file.
deb http://deb.debian.org/debian bullseye main deb-src http://deb.debian.org/debian bullseye main
Once repo is added, I will first try to first update all my packages by running apt-get update command as you can see below.
Then I will again try to install openssh-server package by using
apt-get install openssh-server command as you can see below.
As you can see above, this time it worked and now I am able to install my package. Hence it is confirmed that in my case issue was with the missing repository information in my server.
But what if the repository information is also there and still you are getting the same error ? Well, in that case you need to check other bunch of things that can cause this error. Like, you might have forgotten to run
apt-get update or
apt update command before installing any packages so in that case you need to try updating your Server packages first before installing any new package.
Next, if your Server is already updated then it might be possible that package which you are trying to install is not available in the repository sources you have added. In my case
openssh-server package was available in the repository so I was able to install it but it is possible that you might try to install any package which is not available in the added repository source. So the recommendation is to always verify the list of packages available in the repository before you try to install that package. You can always use
apt-cache search <package_name> command to search a specific package from repository.
root@debian:~# apt-cache search openssh-server openssh-server - secure shell (SSH) server, for secure access from remote machines
You can also verify the package in local package list by using
apt-cache policy <package_name> command as shown below.
root@debian:~# apt-cache policy openssh-server openssh-server: Installed: 1:8.4p1-5 Candidate: 1:8.4p1-5 Version table: *** 1:8.4p1-5 500 500 http://deb.debian.org/debian bullseye/main amd64 Packages 100 /var/lib/dpkg/status
Hopefully above steps makes sense to you and it will help you solving Package "package_name" has no installation candidate error. Please let me know your feedback on comment box.