- Published on
`apt update` yields connection error after updating WSL
- Authors
- Name
- Mai H. Son (Mason)
As of May 29th, 2025, after running wsl --update
on Windows 11, I encountered a persistent issue with the apt update
command in WSL Ubuntu 24.04. The error output was as follows:
Err:2 http://archive.ubuntu.com/ubuntu noble InRelease
Connection failed [IP: 91.189.91.83 80]
Err:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Connection failed [IP: 185.125.190.82 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Connection failed [IP: 91.189.91.83 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease Connection failed [IP: 185.125.190.82 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-backports/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2620:2d:4002:1::103).
Initially, I suspected a DNS issue on the Windows host machine, as I had not modified any network settings for some time. I attempted to reset the DNS to its default configuration, but this did not resolve the problem.
After extensive online research, I found no immediate solution.
I then considered the possibility that the Ubuntu repository servers were temporarily unavailable. Testing the repository URLs in my browser, I noticed that the HTTP links failed to load. However, switching the protocol from HTTP to HTTPS allowed the pages to load successfully.
It appears that Canonical has transitioned their repository URLs to HTTPS and disabled HTTP access. To restore apt update
functionality, it is necessary to update the repository URLs accordingly.
For Ubuntu 24.04, the relevant URLs are stored in /etc/apt/sources.list.d/ubuntu.sources
. For older versions, they are located in /etc/apt/sources.list
. You can update these files manually using your preferred text editor, or by running the following commands:
# For Ubuntu 24.04
sudo sed -i 's|http://security.ubuntu.com|https://security.ubuntu.com|g' /etc/apt/sources.list.d/ubuntu.sources
sudo sed -i 's|http://archive.ubuntu.com|https://archive.ubuntu.com|g' /etc/apt/sources.list.d/ubuntu.sources
# For older versions
sudo sed -i 's|http://security.ubuntu.com|https://security.ubuntu.com|g' /etc/apt/sources.list
sudo sed -i 's|http://archive.ubuntu.com|https://archive.ubuntu.com|g' /etc/apt/sources.list
These commands replace all instances of http
with https
for the Ubuntu repositories. After making these changes, you should be able to run sudo apt update
without encountering connection errors.
I hope this solution proves helpful to others facing the same issue.