apt-get stuck at 0 [Connecting to us.archive.ubuntu.com]

I figured out how to get apt-get to work again.

Edit gai.conf:

sudo vim /etc/gai.conf

change line ~54 to uncomment the following:

precedence ::ffff:0:0/96  100

write and quit:

:wq

CAUTION

Look out line 50 which looks almost identical:

precedence ::ffff:0:0/96  10

This is the wrong line. Go ~4 lines down and you'll find the correct line to uncomment because it ends with 100 instead of 10


It's better to disable the IPV6 before you update and upgrade.

  1. Open Terminal

  2. Enter sudo -H gedit /etc/sysctl.conf and open the configuration file and add the following lines at the end

    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1 
    net.ipv6.conf.lo.disable_ipv6 = 1 
    
  3. After that run

    cat /proc/sys/net/ipv6/conf/all/disable_ipv6 
    

    If it reports ‘1′ means you have disabled IPV6.

    If it reports ‘0‘ then please follow Step 4 and Step 5.

  4. Type command sudo sysctl -p. You will see this in terminal.

    net.ipv6.conf.all.disable_ipv6 = 1 
    net.ipv6.conf.default.disable_ipv6 = 1 
    net.ipv6.conf.lo.disable_ipv6 = 1 
    
  5. Repeat above “Step 3” and it will now report 1.


None of the IPv6 fixes worked for me. Possibly I have the same symptom with a different cause. My workaround was to switch to a different archive by doing a search and replace in sources.list, e.g.:

sudo vim /etc/apt/sources.list

And then:

:%s/us\.archive/de\.archive/g
:wq

This at least allows me to get back to work until I figure out the real problem.