Problem:
When running sudo apt update or other apt commands on an Ubuntu VPS, the process fails or hangs. Users may see errors indicating that us.archive.ubuntu.com is unreachable or times out, similar to the below error:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Unable to connect to us.archive.ubuntu.com:http:W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Unable to connect to us.archive.ubuntu.com:http:W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-security/InRelease Unable to connect to us.archive.ubuntu.com:http:
Cause:
This issue is commonly due to intermittent connectivity problems with the Ubuntu US mirror infrastructure (us.archive.ubuntu.com). These problems are outside the control of your VPS or RackNerd's network, and is a temporary issue with the Ubuntu Archive/mirror server.
Solution:
To resolve this, we recommend switching your system's apt sources from the US-specific mirror to the main Ubuntu archive mirror. The main mirror (archive.ubuntu.com) automatically chooses the fastest and most reliable server based on current conditions.
Steps to Fix:
1. SSH into your VPS.
2. Run the following command to replace the US mirror with the main archive mirror:
sudo sed -i 's/us\.archive\.ubuntu\.com/archive.ubuntu.com/g' /etc/apt/sources.list
After updating the mirror, run:
sudo apt update
Your APT commands should now complete successfully.
Note: This change is persistent across reboots but will be reset if you reinstall the operating system. After any OS reinstallation, remember to repeat the above steps to avoid running into the same issue again.
