I've been trying sudo apt-get update
in Ubuntu 20.04 LTS server, and I was getting the below error.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://ppa.launchpad.net/certbot/certbot/ubuntu/dists/focal/InRelease Temporary failure resolving 'ppa.launchpad.net'
W: Failed to fetch http://rpms.litespeedtech.com/debian/dists/focal/InRelease Temporary failure resolving 'rpms.litespeedtech.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Here's how I fixed it:
Removing bad sources.list
sudo rm -rf /etc/apt/sources.list*
Adding new good sources.list
cd /etc/apt/
wget https://gist.githubusercontent.com/ishad0w/788555191c7037e249a439542c53e170/raw/3822ba49241e6fd851ca1c1cbcc4d7e87382f484/sources.list
Fixing the Ubuntu's connection
sudo dhclient -v -4
sudo echo 'nameserver 8.8.8.8' > /etc/resolv.conf
Running the update command
sudo apt-get update
Hooray! you fixed it.