Ubuntu: apt upgrades failing with “Cannot initiate the connection to ports.ubuntu.com”

By | 6th February 2023

While doing a distro upgrade with

# do-release-upgrade

I kept getting failures half-way stating

Cannot initiate the connection to ports.ubuntu.com:80

The errors showed several IPv6 addresses that couldn’t be reached. My router supports IPv6, but not my ISP. Somehow I was expecting that the router would be doing the translation or DNS resolution between the two but this wasn’t the case.

Disabling IPv6 on the router didn’t to much. I have a recollection that some of the services I am running on my Ubuntu server require IPv6 enabled or else the OS breaks. So it can’t be disabled for the whole OS.

Luckily you can configure apt to only use IPv4:

# apt-get -o Acquire::ForceIPv4=true update

This will automatically refresh the sources and next time you run apt it will complete the upgrade. If not, your problem lies somewhere else.

image_printPrint this page

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.