"apt-get update" Fails? (Kali Linux with Virtual Box)

29,063

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
Share:
29,063

Related videos on Youtube

Colin
Author by

Colin

Updated on September 18, 2022

Comments

  • Colin
    Colin over 1 year

    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.

  • Colin
    Colin over 8 years
    Alright, I'll try that. I didn't catch that little error. Whoops.
  • Colin
    Colin over 8 years
    Unfortunately, the same error appears after the changed source. The only that varied is that the Failed To Fetch URL changed.
  • Colin
    Colin over 8 years
    apt-get outputs the same error, apt-get upgrade doesn't upgrade any packages, and apt-get update --fix-broken outputs the same error. :/
  • NoobNet14
    NoobNet14 over 8 years
    I initially thought it was a network error. Since you have a lot of connect errors listed. Are you able to browse websites in Kali? Are you having other network issues other than the apt-get update?
  • Colin
    Colin over 8 years
    That's a good question, Iceweasel is acting strange, but I can ping any IP fine, including the sources in sources.list. I can also use nmap, etc. on anything.
  • NoobNet14
    NoobNet14 over 8 years
    Are you able to visit Kali's site from inside of Kali? Did you install a good copy of the OS? Did you check hashes make sure not corrupted? Maybe something got corrupted --- if you are positive that your network is 100% working. Thats why a clean install with a good copy might be needed.
  • Colin
    Colin over 8 years
    I am able to visit Kali's website from inside Kali and Iceweasel. I installed the lastest ISO from Kali's official site. I'll try a clean install tomorrow. I really appreciate the help. Thank you.
  • borizzzzz
    borizzzzz almost 5 years
    I know it's an old thread but nowadays there's only the following line you should add according the link you provided: "deb http.kali.org/kali kali-rolling main non-free contrib"