Zach Adams Web Developer and Programmer

Apt-get can't connect to 'security.ubuntu.com'

January 15, 2015

Ran into this issue today where on a newly made Linode Ubunu 14.04 LTS server I ran

apt-get update

The command started alright however eventually it would reach a point where it got stuck at

Connecting to security.ubuntu.com (2001:67c:1562::16)

And wouldn’t continue no matter what. Turns out this is an issue where connecting over IPv6 on some servers causes them to get stuck at this point. The fix is really simple.

OpenĀ /etc/gai.conf

Uncomment the following line:

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

This will allow you to still use IPv6 but sets IPv4 as the precedence so that apt-get won’t get stuck.

Let me know if you have any issues!

Comments

RedEight says:
January 22nd 2015 at 12:00am
Thank you! I'm really confused as to why this issue showed up. Fortunately this was able to get me back up and running on updates. Seems kind of bizarre that this would suddenly become an issue.
Forrest says:
August 8th 2015 at 12:00am
Thanks! This worked on Mint 17.1
Evan says:
November 3rd 2015 at 12:00am
Ran into this with a just-created Ubuntu 15.10 VM inside Hyper V, and this fix worked. The host OS is Windows 10 Pro Insider Preview (build 10565). "security.ubuntu.com" was reachable by both IPv4 and IPv6, so I'm not sure why it hung. Also, based on search results this seems to be an old problem dating back to ~2012. Maybe there was a recent change on the server end that caused this?
Grateful user says:
November 25th 2015 at 12:00am
Thanks a lot! I found your post in a bug report. It's ridiculous that this issue hasn't been permanently solved yet! Thanks for the workaround!
vrna says:
November 28th 2015 at 12:00am
this does NOT work.
Philip says:
January 26th 2016 at 12:00am
Worked great, thanks!
Tyler says:
May 10th 2016 at 12:00am
Thanks for this. I'm in the exact same situation with the Ubuntu 14.04 LTS Linode and your fix worked.
billy noah says:
June 15th 2016 at 12:00am
Thanks - reposted this here: http://askubuntu.com/a/787491/138058
Akshay says:
August 3rd 2016 at 12:00am
Thanks for this. Just ran into the exact same thing on my new linode instance running Ubuntu LTS 16.04. The fixed works great.
Micheal says:
August 13th 2016 at 12:00am
I just installed a local VM copy of Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86-64) on an AMD x64 system with 4GB RAM and a single 4 core CPU. Initially, I had problems with updates and reinstalled a couple of times, wiping the disk each time. I ran across this post and made the change to /etc/gai.conf. However, I still have the same issue. It tries to get to 91.189.19.80 but fails over to 2001:67c:1562::19 every time. I am not running IPv6 on my home network and my IP seems not to be using it as everything is IP v4. Any other ideas??????
John says:
December 16th 2016 at 12:00am
Thanks. it was really helpful because it got me stuck for quite some time.
Arnab says:
March 16th 2019 at 12:00am
Thanks! Worked for Ubuntu 16.04 (64 bit)
Chris says:
August 13th 2020 at 12:00am
This solved it, thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *