sudo add-apt-repository hangs

12,487

Solution 1

I have followed this instructions, and it worked great for me (Ubuntu 20.04).

In command line, type this

sudo gedit /etc/gai.conf

Then, edit this line by removing the #

precedence ::ffff:0:0/96  100

Solution 2

In my case I was having problems handling ipv6 from the responses. I was getting a blinking cursor and had to wait, sometimes, for one minute so it would work, although the requests which were handled from the beginning only with ipv4 were working fast and fine.

I discovered this when checked the behavoiur of the terminal command wget. Google which defaults requests on ipv6 at port 80 (http) was taking more than a minute to timeout and use ipv4 [and finally work]; then github.com that only uses ipv4, also on port 80 (http), was working ok.

Not all requests go through ipv6, many still use ipv4 as default and sometimes is the only valid answer. It doesn't matter if we are using wget, curl or add-apt-repository (which i think uses python 3.6.9 socket and all of its network libraries) those all try to resolve the ipv6 at first.

In my case, i had to have a valid ipv6 address to make a request (from my computer) and although the IPS modem and my router were configured to handle ipv6, this computer which originally had Windows 10 (removed from ssd) then had Ubuntu 18.04 (full installation) installed was not completely configured. I had to go to wifi settings and select to get an automatic ipv6 address and settings (DHCP), that was it for me. Make sure you select for ipv6 "Automatic, DHCP only" and not only "Automatic" as there are both available choices.

Apparently when we are working from the terminal in Ubuntu, it tries to resolve the first available address that in this cases was ipv6. So now i can get everything fast, since my pc can resolve the requests through ipv6 very fast and translates them to the ipv4 address.

Share:
12,487

Related videos on Youtube

a curious engineer
Author by

a curious engineer

Updated on September 18, 2022

Comments

  • a curious engineer
    a curious engineer over 1 year

    I am running sudo add-apt-repository ppa:webupd8team/java in order to add the repository to install oracle jdk on my Ubuntu 18.4 machine. The command hangs and does not return. As far as I understand all this command does is to add the repository to the /etc/apt/sources.list file. Could the reason for the command hanging be that i am running this behind a proxy?

    How can I resolve this issue?

  • hsandt
    hsandt over 3 years
    I got this issue after switching to another WiFi, and setting "Automatic, DHCP only" worked but I had to disconnect and reconnect to that WiFi. I don't know if just disconnecting and reconnecting would have worked, so I'd recommend others to try this first (or keep using the WiFi connect that usually works, if still available).
  • applemonkey496
    applemonkey496 about 3 years
    It worked for me (on 20.04) but I had to run sudo service network-manager restart first
  • mattbell87
    mattbell87 over 2 years
    This worked for Linux on the chromebook, thankyou
  • Admin
    Admin almost 2 years
    Worked for me on Windows 10 + WSL2 environment as well