Friday, August 12, 2016

A “failed to fetch” error occurs when apt-get update is run. How do I fix this?

I was facing the same problem and figured the easiest solution is to reset the sources of /etc/apt/sources.list. To do so, follow these steps:
  1. Obtain the release of your Ubuntu version, type into the console:
    lsb_release -r
  2. Go to http://repogen.simplylinux.ch/ to generate a new sources.list
  3. Select your country & release
  4. Check the first 12 boxes:
    All Ubuntu Brances + Security & Updates
  5. Generate and copy your new list
  6. Backup the old file to sources.list.old
    mv /etc/apt/sources.list /etc/apt/sources.list.old
  7. Open vim to save the new list
    vi /etc/apt/sources.list
  8. Paste and save using :wq
  9. G2G, retry running apt-get update


If you are getting below error then remove broken repository.

W: The repository 'http://ppa.launchpad.net/colingille/freshlight/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.


$ sudo add-apt-repository --remove ppa:colingille/freshlight
 This PPA contains my free softwares.
Website: http://www.congelli.eu/
 More info: https://launchpad.net/~colingille/+archive/ubuntu/freshlight
Press [ENTER] to continue or ctrl-c to cancel removing it


If you are getting below error:


W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources  Hash Sum mismatch, 
E: Some index files failed to download. They have been ignored, or old ones used instead.

then just remove all the content of /var/lib/apt/lists directory and update.

sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update

A “failed to fetch” error occurs when apt-get update is run. How do I fix this?

I was facing the same problem and figured the easiest solution is to reset the sources of /etc/apt/sources.list. To do so, follow these steps:
  1. Obtain the release of your Ubuntu version, type into the console:
    lsb_release -r
  2. Go to http://repogen.simplylinux.ch/ to generate a new sources.list
  3. Select your country & release
  4. Check the first 12 boxes:
    All Ubuntu Brances + Security & Updates
  5. Generate and copy your new list
  6. Backup the old file to sources.list.old
    mv /etc/apt/sources.list /etc/apt/sources.list.old
  7. Open vim to save the new list
    vi /etc/apt/sources.list
  8. Paste and save using :wq
  9. G2G, retry running apt-get update


If you are getting below error then remove broken repository.

W: The repository 'http://ppa.launchpad.net/colingille/freshlight/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

$ sudo add-apt-repository --remove ppa:colingille/freshlight
 This PPA contains my free softwares.
Website: http://www.congelli.eu/
 More info: https://launchpad.net/~colingille/+archive/ubuntu/freshlight
Press [ENTER] to continue or ctrl-c to cancel removing it