How to fix apt "Cannot initiate the connection" on Ubuntu headless

Today, while updating my Ubuntu headless server, I got some errors from the mirror I was using:

sudo apt-get update

Err:1 http://fi.archive.ubuntu.com/ubuntu xenial InRelease
Cannot initiate the connection to fi.archive.ubuntu.com:80

connect (101: Network is unreachable) 

...and so on.

Seems there is some problem with fi.archive.ubuntu.com, or maybe they stopped serving updates for my old LTS version of Ubuntu.

This was solved with some editing of /etc/apt/sources.list

sudo nano /etc/apt/sources.list

I replaced http://fi.archive.ubuntu.com/ubuntu/ with mirror://mirrors.ubuntu.com/mirrors.txt. If you want to be sure, leave the old lines there commented with #, so you can go back if this doesn't help.

So the lines would look like this now:

deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted 
# deb http://fi.archive.ubuntu.com/ubuntu/ xenial main restricted 

deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted
# deb http://fi.archive.ubuntu.com/ubuntu/ xenial-updates main restricted


After that, apt-get update and apt-get upgrade started working again.

From now on, you shouldn't need to change mirrors yourself when there are changes. They are now loaded automatically from the text file http://mirrors.ubuntu.com/mirrors.txt.

Comments

Popular posts from this blog

How to install and play Curse of Monkey Island on Android

How to fix the weird audio bug in Kingdom Come: Deliverance

How to get rid of coil whine just by tweaking BIOS

Fix the login loop in Xubuntu 24.04

How to find the ScummVM game folder on Android

Create a sleep timer for Youtube, Twitch, Netflix etc. on Windows 10