18

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?

5
  • 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
  • 2
    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, 2022 at 12:24

2 Answers 2

29

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
5
  • 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, 2022 at 13:26
  • Worked on LinuxLite, Thanks!
    – vasiauvi
    Jan 3, 2023 at 19:14
  • Thank you so much!!!
    – Roman M
    Sep 28, 2023 at 12:28
  • I can't edit this file on Ubuntu Touch. Is there another way to achieve the same without requiring some special permissions that even sudo doesn't have?
    – Joooeey
    Feb 27 at 11:03
8

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.

2
  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .