6

When I run sudo apt-get update, it gets stuck at Connecting to ...

$ sudo apt-get update
0% [Connecting to archive.ubuntu.com (2001:67c:1360:8001::17)]

That's all the command outputs. Does anyone know what's wrong?

Zanna
  • 70,465

2 Answers2

6

It looks like the computer believes it has IPv6-connectivity, whilst it in fact does not have it. This can be verified by trying the command ping6 www.google.com.

You can disable IPv6 on Ubuntu, by running the following command. To enable IPv6 again,simply do rm /etc/sysctl.d/99-disable-ipv6.conf

echo "net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee /etc/sysctl.d/99-disable-ipv6.conf

You can also create this file, using a text editor, and pasting the content

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Then run sudo service procps reload to reload.

muru
  • 197,895
  • 55
  • 485
  • 740
vidarlo
  • 22,691
2

I had this issue, but was solved instantly by following the steps below:

a) open terminal and run the command sudo nano /etc/gai.conf

b) Scroll down in the file gai.conf using the arrow keys and remove the comment(#) from the line: #precedence ::ffff:0:0/96 100

Save the file by pressing Ctrl+O and then exit by pressing Ctrl+X

slava
  • 3,887
  • 1
    Although not required, it helps sometimes to explain why this works: Your network is not responding well to IPV6 addresses (my ISP does not use IPV6 at all, and I'm near Seattle). This line gives precedence to IPV4 addresses in GetAdrressInfo. – Charles Green Feb 16 '19 at 21:40