Menu Close

Could not connect to security.ubuntu.com:80

I got a bunch of network failure error when trying to run $ sudo apt update on my Ubuntu. The error looked like this

$ sudo apt update
Hit:1 https://download.mono-project.com/repo/ubuntu stable-focal InRelease
Hit:2 http://packages.microsoft.com/repos/vscode stable InRelease
Hit:3 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:4 https://download.virtualbox.org/virtualbox/debian focal InRelease
Hit:5 https://debrepo.freedownloadmanager.org bionic InRelease
Err:6 http://linux.dropbox.com/ubuntu disco InRelease
Could not connect to linux.dropbox.com:80 (99.84.199.107), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.46), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.93), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.121), connection timed out
Err:7 http://my.archive.ubuntu.com/ubuntu focal InRelease
Could not connect to my.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1360:8001::23), connection timed out Could not connect to my.archive.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1562::15), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1360:8001::24), connection timed out
Err:8 http://my.archive.ubuntu.com/ubuntu focal-updates InRelease
Unable to connect to my.archive.ubuntu.com:http:
Err:9 http://my.archive.ubuntu.com/ubuntu focal-backports InRelease
Unable to connect to my.archive.ubuntu.com:http:
Err:10 http://security.ubuntu.com/ubuntu focal-security InRelease
Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1360:8001::24), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1562::15), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1360:8001::23), connection timed out
Reading package lists… Done
Building dependency tree
Reading state information… Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://download.mono-project.com/repo/ubuntu stable-focal InRelease' doesn't support architecture 'i386'
W: Failed to fetch http://my.archive.ubuntu.com/ubuntu/dists/focal/InRelease Could not connect to my.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1360:8001::23), connection timed out Could not connect to my.archive.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1562::15), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to my.archive.ubuntu.com:80 (2001:67c:1360:8001::24), connection timed out
W: Failed to fetch http://my.archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Unable to connect to my.archive.ubuntu.com:http:
W: Failed to fetch http://my.archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Unable to connect to my.archive.ubuntu.com:http:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1360:8001::24), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1562::15), connection timed out Could not connect to security.ubuntu.com:80 (2001:67c:1360:8001::23), connection timed out
W: Failed to fetch http://linux.dropbox.com/ubuntu/dists/disco/InRelease Could not connect to linux.dropbox.com:80 (99.84.199.107), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.46), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.93), connection timed out Could not connect to linux.dropbox.com:80 (99.84.199.121), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.

The cause

I was guessing that I had some issues with my DNS resolver, and turned out I was right. After changing my DNS resolver, my update went fine again.

The solution

It is a pretty simple solution, which is changing your DNS resolver. I am going to show how to do it if you are using systemd-resolved. How do you check if you are using systemd-resolved? just do

$ sudo systemctl status systemd-resolved.service

and you will see something like below

Could not connect to security.ubuntu.com:80 1

Step 1 – Change DNS resolver

Edit the configuration file. I am going to use nano. Feel free to use your own file editor.

$ sudo nano /etc/systemd/resolved.conf

Uncomment these 2 lines and configure

DNS= 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Domains=~.

This will use Google Public DNS. You can change it in case you want to use other DNS resolver such as Cloudflare.

You can see how your configuration should look like in image below.

Could not connect to security.ubuntu.com:80 2

Hit CTRL+X and type y, then ENTER to save and exit.

Step 2 – Restart systemd-resolved

Restart systemd-resolved

$ sudo systemctl restart systemd-resolved.service

Step 3 – Verify

Ensure you did them right. Run

$ resolvectl status

and you should something like this

Could not connect to security.ubuntu.com:80 3

You will see your new DNS resolver at Current DNS Servers and DNS Servers.

You can quit the screen by hitting q key on your keyboard and you are done. You can now do $ sudo apt update and have it working.

4.2 5 votes
Article Rating
Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
yus

i have similar problem, but this not work for me

vrno

I can ping but still the same error.

sudo systemctl status systemd-resolved.service
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down

4
0
Would love your thoughts, please comment.x
()
x