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?

  • 4
    Possible duplicate of Configure proxy for APT?
    – Pilot6
    Mar 5, 2019 at 10:28
  • I am using the solution in the post above for apt to work behind the proxy. This however does not help me with my current issue. apt is working behind the proxy but add-apt-repository hangs Mar 6, 2019 at 8:00
  • 1
    having the same issue, but not behind a proxy. sudo add-apt-repository hangs and has to be terminated using Ctrl+C May 4, 2019 at 9:59
  • 1
    I had the same issue with another PPA and could fix it by following these Instructions. May 7, 2019 at 17:39
  • I had same issues with another PPA and utilizing an enterprise proxy, and this askubuntu.com/a/1048168/365230 answer helped (sudo -E ..)
    – Aydin K.
    Feb 21 at 12:24

2 Answers 2


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
  • This worked for Linux on the chromebook, thankyou
    – mattbell87
    Dec 27, 2021 at 5:17
  • Worked for me on Windows 10 + WSL2 environment as well Jun 8 at 13:26

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.

  • 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).
    – hsandt
    Dec 5, 2020 at 12:16
  • It worked for me (on 20.04) but I had to run sudo service network-manager restart first Feb 20, 2021 at 1:48

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.