Error while updating ubuntu repository sources list [duplicate]

Solution 1:

Revert your repositories list to the original Ubuntu Focal list by running the following command in the terminal:

sudo nano /etc/apt/sources.list

A file editor will be opened. Delete all the lines in it and then copy and paste the following in the file editor:

deb http://archive.ubuntu.com/ubuntu focal main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse universe restricted

Then, save and close the file by pressing Ctrl + X then press Y then press Enter

To verify you saved the file correctly, please run the following command in the terminal:

cat /etc/apt/sources.list

The output should be exactly:

deb http://archive.ubuntu.com/ubuntu focal main universe multiverse restricted
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse universe restricted
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse universe restricted

Ubuntu repositories have a defined format. They should be for example something like deb http://archive.ubuntu.com/ubuntu bionic main.

Explanation:

deb: These repositories contain binaries or precompiled packages. These repositories are required for most users.

http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location on the internet.

focal: is the release name of your Ubuntu installation.

main & restricted ...etc: are the section names or components. There can be several section names, separated by spaces.

After that, please clear apt cache by running the following command in the terminal:

sudo apt clean && sudo apt autoclean

Then update your repositories list by running the following command in the terminal:

sudo apt update

You should now be able to install packages and update your system again.

If after that, you still get errors, please first back up /etc/apt/sources.list.d/ to your home directory by running the following command in the terminal:

mkdir ~/old_sources_list_d && sudo cp -r /etc/apt/sources.list.d/* ~/old_sources_list_d/

After that, please clear all existing PPAs and repository lists in /etc/apt/sources.list.d/ by running the following command in the terminal:

sudo rm -r /etc/apt/sources.list.d/*

After that, please clear apt cache by running the following command in the terminal:

sudo apt clean && sudo apt autoclean

Then, please update your repositories list by running the following command again in the terminal:

sudo apt update

Notice:

  • Check if your connection to the Internet is behind a firewall, limited in any way or behind a proxy and configure your system and connection accordingly or change to a different connection if available. Firewalls can block access to certain URLs and proxies can keep old stale links in their cache system and this would result in broken or unresponsive targets. Proxies can also modify the headers of the HTTP requests and interfere with responses from web-servers and change them and your computer might end up getting faulty responses that APT can not handle correctly. This is common in networks that are used by large number of people and limited resources or Internet speed for availability and security reasons.

  • Check if there is an APT proxy configuration file by running the following command:

ls /etc/apt/apt.conf.d/*proxy*

If the command returns back any results, move these files out of the /etc/apt/apt.conf.d/ directory or delete them.