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

When I do upgrade it gets stuck here:

user@plato:~# sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  bind9-host coreutils cpio curl dnsutils libbind9-90 libc-bin libc-dev-bin
  libc6 libc6-dev libcgmanager0 libcurl3 libcurl3-gnutls libdns100
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libisc95 libisccc90
  libisccfg90 libjasper1 liblwres90 libplymouth2 libsepol1 libssl-dev
  libssl-doc libssl1.0.0 linux-libc-dev mime-support multiarch-support ntp
  ntpdate openssl plymouth plymouth-theme-ubuntu-text python3-distupgrade
  ubuntu-release-upgrader-core unzip
39 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.0 MB of archives.
After this operation, 12.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
0% [Connecting to us.archive.ubuntu.com (2001:67c:1562::15)] ░

When I do update it gets stuck here:

user@plato:~# apt-get update
0% [Connecting to us.archive.ubuntu.com (2001:67c:1562::14)] [Connecting to sec░

I'm able to ping us.archive.ubuntu.com just fine:

user@plato:~# ping us.archive.ubuntu.com
PING us.archive.ubuntu.com (91.189.91.23) 56(84) bytes of data.
64 bytes from economy.canonical.com (91.189.91.23): icmp_seq=1 ttl=54 time=81.5 ms
64 bytes from economy.canonical.com (91.189.91.23): icmp_seq=2 ttl=54 time=81.5 ms
64 bytes from economy.canonical.com (91.189.91.23): icmp_seq=3 ttl=54 time=81.5 ms
64 bytes from economy.canonical.com (91.189.91.23): icmp_seq=4 ttl=54 time=81.4 ms
^C
--- us.archive.ubuntu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 81.425/81.528/81.582/0.355 ms

What can i do to fix this?


What I have tried so far.

I've tried following directions on this blog: http://nickescobedo.com/719/ubuntu-apt-get-hangs-at-0

To force apt-get to use IPv4 exclusively

  • Create a file in /etc/apt/apt.conf.d/99force-ipv4
  • Add this line to newly created file Acquire::ForceIPv4 false;
  • Apt-get will now use IPv4 exclusively

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.