Ubuntu: add-apt-repository hangs

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1480
Joined: Fri Aug 29, 2003 8:39 pm

Ubuntu: add-apt-repository hangs

Post by ^rooker »

[PROBLEM]
Trying to add a new PPA, using the (already) good-old "add-apt-repository" just hangs and waits forever. Nothing happens. Probably timeout of some kind.
I run into this on every new installation since 18.04, and I keep forgetting what it was. Shame on me...

[SOLUTION]
APT is trying IPv6, but won't get anywhere.

Thanks to Zach Adams fix suggestion (2015), I now now a better way than disabling IPv6 for APT:


1) Open /etc/gai.conf
Make a backup of it before. Just in case. For example copy it to "/etc/gai.conf.org"

2) 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."
That's it! :D
Thanks Zach!
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply