Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save harryfinn/d2850bd96d242a3553571fc5f386781a to your computer and use it in GitHub Desktop.
Save harryfinn/d2850bd96d242a3553571fc5f386781a to your computer and use it in GitHub Desktop.
security.ubuntu.com timeout on apt-get update

security.ubuntu.com timeout on apt-get update

Issue

When running the apt-get update command, the process 'hangs' when checking security.ubuntu.com endpoints. This is apparantely due to an issue some sites face when trying to connect over IPv6 and whilst it is assumed that this will be fixed at some point in the future (sooner rather than later judging by the transition to IPv6 by most), the fix below resolves this issue, allowing the update process to complete successfully.

Fix

Edit /etc/gai.conf and uncomment the following line: precedence ::ffff:0:0/96 100. This is found directly under this comment: # For sites which prefer IPv4 connections change the last line to

Re-run apt-get update after saving the gai.conf file and you'll see the process complete successfully. All we've done is to all IPv4 connections for sites which prefer this connection protocol for now and seeing as the public web is still running across IPv4, this is OK to do for now!

@akashkj
Copy link

akashkj commented Sep 1, 2018

It worked by modifying the file. Why does it stopped working prior to this, any idea?

@ayrat555
Copy link

ayrat555 commented Mar 1, 2020

It worked by modifying the file. Why does it stopped working prior to this, any idea?

@harryfinn I have the same question. Thanks anyway! It helped

@ahembal
Copy link

ahembal commented Dec 18, 2020

Thanks for your answer, and by the way it gives an error "permission denied" when you want to save file. I found "sudoedit /etc/gai.config", after this, I was able to change that part and it worked.

@cunneen
Copy link

cunneen commented Dec 1, 2021

Thank you it worked for me

@overgenie
Copy link

Thank you some much i was strugling to this for a week now !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment