hostapd is a Linux daemon capable of turning normal network interface to an access point and authentication servers. In other words, hostapd can make a WiFi access point out of your "host" computer.
hostapd is commonly used internally by pen-testing programs and scripts. Usually it is installed by default on most Linux distros which focus on security. If it's not, you can easily get it by running
apt-get install hostapd. But recently, users reported that they got
E: Unable to locate package hostapd when trying to install the software, sometimes even after they got their package database updated.
This article is going to show you a few possible solutions to fix "Unable to locate package hostapd" on Debian-based Linux distros such as Kali Linux, Ubuntu, Tails, etc.
Make sure apt database is up to date
By default, whenever an user tries to install a piece of software,
apt searches in its database to look for an exact match and perform the installation. The
apt database is regularly updated from a list of "repository" and store locally. In rare cases, the update process can be interrupted and the database lags behind recent changes or miss a few bits of information. You can manually update
apt package library by running the following command :
sudo apt-get update
Once the update is done, try installing hostapd again to see if the problem goes away. If it's not, there are a few more possible solutions in the next section.
Reset the repository list of Kali Linux
The list of all repositories which
apt pulls data from is located in
/etc/apt/sources.list. You may have populated sources.list with many unofficial repositories, therefore the system confuses between which repositories to look for the package you want. To solve this, you may switch to Kali Linux "rolling" repository list to grab the newest version of hostapd.
The official repository list of Kali can be found at https://docs.kali.org/general-use/kali-linux-sources-list-repositories.
First you need to make a backup of your current
sources.list so that you can revert back if anything goes wrong. Run the following command to rename the file :
mv /etc/apt/sources.list /etc/apt/sources.list.backup
Then you will need to create a new
sources.list with only one single, official repository :
echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" > /etc/apt/sources.list
The last thing you have to do before trying to install the package again is updating the system with
sudo apt update. If that completes successfully, you should be able to install hostapd without issues.
Clean your sources.list file
If you see
Unable to locate package hostapd error message on a machine which runs on other Linux distro, double check your
/etc/apt/sources.list. Most of the time, it contains either unofficial repositories or obsolete mirror of official repositories. Comment out any line that seems suspicious, then
apt-get update and try to install hostapd again to see if it goes well.
If possible, you can copy the same file in another clean machine (in which the installation runs without issues) and replace it in your system. After that,
apt-get update and you should be able to install hostapd again.
Last resort : install hostapd from DEB file
Debian-based distro supports installing packages from DEB file. This installation method does not include dependencies, you have to install them separately. As a last resort, you can grab hostapd DEB file for your distribution at https://pkgs.org/download/hostapd then run this command to depackage it :
sudo dpkg -i hostapd_xxxx.deb
hostapd_xxxx.deb with your downloaded filename.
We hope that after finishing this article, you solved
E: Unable to locate package hostapd on your system. If you feel the whole
apt-get installation is too cumbersome, consider trying AppImage - a new way to package programs to be portable, so they do not require too much fiddling with internal parts of the operating system.