Thursday, October 03, 2019

apt-get update - stops at "0 [ Connecting to us.archive.ubuntu.com ]"


I've been trying to update my UBUNTU 16.04 and it kept hanging up and not completing the updates. So I opened a TERMINAL window and typed in the following command, which is one of the two commands you use to update Ubuntu from the command line.

    sudo apt-get update

When pressing ENTER after typing in this command you will see a list of software sources that Ubuntu is checking to see if there are any updates you need for the software you have installed and there will be a percentage completed number at each line.  Well I noticed that mine was getting stuck at the following line and kept reading 0%

0 [Connecting to us.archive.ubuntu.com]

Without the list of what software you need to download and install you can't use the second command to finish your updates;  sudo apt-get upgrade

--------------------------------------------------------------

To fix this you have to edit the gai.conf file.  To do this open a TERMINAL window and type;

sudo gedit /etc/gai.conf

This will launch GEDIT and open the gia.conf file.  Now you have to be CAREFUL here because there is another line that looks almost like the one you have to change, you have to change just ONE line, you have to find the line;

     #precedence ::ffff:0:0/96  100

now just delete the # which uncomments it.  Change it to;

     precedence ::ffff:0:0/96  100

Now save the file and your done.

NOTE:  There is another line that reads #precedence ::ffff:0:0/96  10 DO NOT CHANGE THIS LINE.  You are looking for the line that ends with a 100.


In case you are wondering this what is causing the problem.  This is from the Ask Ubuntu article where I found the solution.

"ISPs are starting to setup an internal IPv6 network in preparation for eventually connecting to the IPv6 internet. As a result, servers in this network now try to connect to *.ubuntu.com via its IPv6 address by default when running apt-get. Solution: uncommenting precedence ::ffff:0:0/96 100 allows requests to prefer IPv4"