I have a Ubuntu 11.10 server that I just installed fresh. Now if I try to do anything with apt-get, it tries to connect to archive.ubuntu.com .. It stays at [Connecting to archive.ubuntu.com (2001:67c:1360:8c01::1a)] phase for like 2 minutes, after which it actually starts to communicate and download stuff ...

Eventually it always connects, but in waits at the [Connecting to archive.ubuntu.com (2001:67c:1360:8c01::1a)] phase everytime for like 2 minutes !

I didn't have this problem previously on Ubuntu 11.10, right after reinstalling the OS ..

Any ideas on what the problem might be ?

  • I wonder if it has to do with the fact you're using IPv6. Are you on an IPv6 network?
    – Thomas Ward
    Mar 26, 2013 at 20:28
  • No I don't think so. I haven't configured any such thing ..
    – Ahmad
    Mar 26, 2013 at 20:36
  • The IPs in your included messages is IPv6. That suggests it's using IPv6, and if I"m not mistaken there aren't that many IPv6 servers for the archive.
    – Thomas Ward
    Mar 26, 2013 at 20:46
  • 1
    @Ahmad Since you've solved your problem and have written the solution, please post it as an answer (and then you can edit it out of your question, too). Please note that you do not need to wait to do this; only users with less than 100 reputation must wait before answering their own questions. You can even mark your own answer as accepted (though for that you must wait until two days after you posted the question have passed). Mar 26, 2013 at 22:15
  • Done .. Now I just have to wait for 22 hours in order to be able to accept my own answer :)
    – Ahmad
    Mar 27, 2013 at 21:32

3 Answers 3


I solved this on 12.10 by editing /etc/gai.conf and uncommenting the line:

#    For sites which prefer IPv4 connections change the last line to
precedence ::ffff:0:0/96 100

This lets you keep IPv6 enabled, but sets the order of precedence to prefer IPv4 over IPv6.

  • 13
    Im not supposed to write ty as a comment but i think it ought be said ur my hero tytytytytyty Nov 12, 2013 at 2:25
  • 1
    This is the answer
    – kbuilds
    Jul 17, 2014 at 11:21
  • 3
    Confirmed on Ubuntu 14.04/ElementaryOS freya as well!
    – oikonomopo
    Dec 29, 2014 at 14:08
  • 2
    perfect! worked a charm!
    – John
    Mar 11, 2015 at 18:16
  • 2
    Still valid for Xubuntu 15.04
    – Dag
    Jul 30, 2015 at 8:10


I figured out the problem. I had to disable IPv6 connectivity, as The Lord Of Time pointed out.

Running the following command in Terminal tells if IPv6 is enabled or not:

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

0 means its enabled, while 1 means its disabled.

To disable IPv6 from within Terminal, enter the following:

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Re-run the first command, and it should be 1 now.

  • I don't have that file...
    – amadib
    Jun 25, 2016 at 16:32
  • Disabling IPv6 is not a solution. It's a workaround. We need IPv6 and disabling it is definately not recommended. The correct solutions are either forcing APT to use ipv4 only, or setting the precendence as shown in the top solution.
    – mniess
    Oct 13, 2016 at 9:52

If you only want to modify apt-get, then you can force IPv4 with:

apt-get -o Acquire::ForceIPv4=true update

To make the setting persistent, create the file 99force-ipv4 in /etc/apt/apt.conf.d/.

sudoedit /etc/apt/apt.conf.d/99force-ipv4

Put the following contents in it:

Acquire::ForceIPv4 "true";

Save the file, and you're good to go. If you want to force IPv6 instead, change the 4 to 6 in the file name and settings. To choose between one of them, test with the fast method and see which works better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.