Linux – “apt-get update” Fails? (Kali Linux with Virtual Box)

aptapt-getkali-linuxlinuxvirtualbox

I just recently installed Kali Linux 2.0 (64-Bit) on Virtual Box with a Windows 7 (64-Bit) host. I have problem with apt-get, and the simple question here is, how can I fix it?

Unfortunately running:" apt-get update ", returns with an error message as follows:

(If you see something that isn't quite right, I just typed that by hand because I can't get bridged clipboards to work. )

root@kali~# apt-get update

0% [Connecting to http.kali.org (192.99.200.113)}]

That "0%" message stays there for thirty seconds then disappears after the error message appears.

Err http://http.kali.org sana InRelease

Err http://http.kali.org sana/updates InRelease

Err http://http.kali.org sna Release.gpg  
   Unable to connect to http.kali.org:http:  
Segmentation fault
Reading package lists... Done  
W: Failed to fetch http://http.kai.org/kali/dists/sana/InRelease

W: Failed to fetch http://http.kali.org/kalisecurity/dists/sana/updates/InRelease  

W: Faied to fetch http://http.kali.org/kali/dists/sana/Release.gpg
   Unable to connect to http.kali.org:http:

W: Some index files failed to download. They have been ignored, or old ones used instead.

This is what resides in etc/apt/sources.list:

deb http://http.kali.org/kali sana main non-free contrib
deb http://http.kali.org/kali-security sana/updates main contrib non-free

Pinging the source IP and the URL works fine, as well as pinging random IPs (google.com, 8.8.8.8, etc), so it's probably not my network.

I tried some regular fixes, but none of them work. I don't have any idea what to do.

Thank you in advance to anyone who helps me, whether or not it works. 🙂

(If you need additional information just tell me.)

Best Answer

The solution is to change mirror in sources.list file. For some reason the default mirror is not working.

There are several mirrors of the Kali Linux repository server, all of which are spread over the world. Each time you interact with the repository, by default it will automatically use the mirror that is closest to you based on your geoip location (idea being, this will give you the best speed due to less latency).

However, you can manually force kali to use a certain/different mirror rather than the one that is nearest you.

Go to http://http.kali.org/README.mirrorlist where you will have a list of mirrors to chose from.

First backup your current source file

mv /etc/apt/sources.list /etc/apt/sources.list.backup

Then create a new sources.list file

vim /etc/apt/sources.list

and enter new mirror.

For example,

old sources.list file was

deb http://http.kali.org/kali kali-rolling main contrib non-free

The new sources.list file can be

deb http://archive-2.kali.org/kali kali-rolling main contrib non-free

Here you have to play around a little bit to find the mirror that works for you.

Then in terminal type:

sudo apt clean
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
Related Question