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. You can now either open vi to save the new list by doing:

    vi /etc/apt/sources.list
    (Paste and save using `:wq`)
    

    Or by copying and pasting into your terminal the "curl" command (including a unique URI for your updated source list) as it is presented under "Sources List" on the repogen output page.

  8. G2G, retry running apt-get update


Edit /etc/resolv.conf. In a Terminal window run

sudo gedit /etc/resolv.conf

and add the line

nameserver 8.8.8.8

and save. Then do

ping www.google.com

If this succeeds then run the following commands

sudo apt-get --download-only --reinstall install resolvconf
sudo dpkg --purge --force-depends resolvconf
sudo apt-get install resolvconf

If resolving now fails then right-click on the network indicator in the bar at the top of the desktop, click Edit Connections, select your connection, Click Edit | IPv4 Settings. Change Method from Automatic (DHCP) to Automatic (DHCP) addresses only and enter 8.8.8.8 in the Additional DNS servers field. Click Save.... Verify that /etc/resolv.conf now contains a line nameserver 8.8.8.8 and that you can still ping www.google.com.


sudo apt-get update finally worked! I just realized that the problem was not on the system but instead how the system connects and retrieves data from the internet. I just configured my Network settings and changed the proxy detection to Manual and filled in the HTTP, HTTPS, FTP, and Socks Host blanks the proxy that I use. When I updated again, this error output happened at first:

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/)

Well, not exactly like the same but similar to it (I copied above from here). But when I tried updating again, it finally worked(the reason I posted the error output above and not the exact output I saw) and I can now choose a different mirror server. If the Network proxy configuration was really the reason for my woes, well, I kinda felt stupid for such basic mistake.

Anyway, thanks everybody for your help! :)