PPA seems to be constantly offline. Whenever I use sudo apt-get update, this error is shown:

W: Failed to fetch http://ppa.launchpad.net/ 404  Not Found

How do I fix these errors?

  • Since this seems to be one of the main "Failed to fetch" answers, I just want to point out here that this also can happen with Ubuntu "partner" URLs in the sources.list; check your errors to see if those are the ones and try commenting them out. I ran into that issue (and solution) upgrading from Quetzal. – joseph_morris May 14 '14 at 22:31
up vote 282 down vote
+200

Automated removal

skip to the bottom of this answer for a scripted way to remove offending software-sources for all ubuntu versions prior to Ubuntu 15.04

What are 404 errors

The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested.

The web site hosting server will typically generate "404 - Page Not Found" web page, when users attempts to follow a broken or dead link.

What are the causes of these errors in update-manager

Typically, three main areas cause these errors in update-manager

  1. A user has just upgraded and has re-enabled a PPA software-source that no longer exists enter image description here
  2. A user has manually typed in a new software source incorrectly enter image description here
  3. A PPA was added, but the maintainer has subsequently deleted some/all of the PPA

where are these software-sources

PPAs typically are saved in one of two locations

  1. /etc/apt/sources.list
  2. in an appropriately named file with a .list file-extension in /etc/apt/sources.list.d/ for example webupd8team-jupiter-natty.list

This list file typically contains:

deb http://ppa.launchpad.net/webupd8team/jupiter/ubuntu oneiric main
# deb-src http://ppa.launchpad.net/webupd8team/jupiter/ubuntu oneiric main

Note a # at the front of a line of text means that it is commented out and is not checked by the package manager.

How to eliminate these errors

Typically, if you run sudo apt-get update from a terminal or click the details button in Update Manager after hitting the refresh button you will see errors such as:

enter image description here

If the error is due to a PPA - usually unticking the similarly named PPA with the URL shown in the error message will resolve this.

enter image description here

If the 404 error was due to an additional repository that has been added to /etc/apt/sources.list then its easier to add # character to the start of the line to comment out the offending repository i.e.

gksu gedit /etc/apt/sources.list

enter image description here

Scripted removal for all ubuntu versions prior to 15.04

I've written a quick script that checks for PPAs and Software-Sources that exhibit the 404 errors. This works for all Ubuntu versions before 15.04. For 15.04 and later perform the manual methods described above.

Its in my PPA:

sudo add-apt-repository ppa:fossfreedom/packagefixes
sudo apt-get update
sudo apt-get install banish404

You can just download the deb package and install that directly:

wget https://launchpad.net/~fossfreedom/+archive/packagefixes/+files/banish404_0.1-4_all.deb
sudo dpkg -i banish404_0.1-4_all.deb

N.B. its the same deb package for all distributions.

Questions/Comments/Improvement please via Launchpad Contact Me link

How to use:

sudo banish404

The script will automatically backup of your sources before modification - to be found in /etc/apt

More info

Here is a bug report on the update manager to solve this problem:

If you are getting these problems without PPAs, check out this question:

  • 2
    Using now to hopefully fix my problem - for peace of mind it'd be great if you could add a link [or short section] on how to 'restore' from the backup if needed – Louis Maddox Aug 22 '15 at 18:01
  • 1
    If you remove these ppas does that imply you need to be getting the relevant updates from somewhere else? – Addem Jan 1 '17 at 22:39
  • 3
    @fossfreedom Why doesn't this work above 15.04? – Mark Yisri Mar 21 '17 at 8:57
  • I used the scripted removal for ubutu 14.04. It worked great. Thanks a lot. – Mohit Mittal Dec 22 '17 at 6:26
  • Note - scripted solution does not work on Ubuntu Server without setting up a display (Tested on 14.04 LTS). – cerd Jan 5 at 14:43

Automated Removal of 404 Not found PPA's through script

This is a script to remove automatically all the 404 Not found PPA's.Copy the below code and paste it into a file and name it as ppa-remove.

#!/bin/bash
sudo rm /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait" 
sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; sort -u /tmp/awk1.txt > /tmp/awk2.txt
tput sgr0
if [ -s /tmp/awk2.txt ]
then
  tput setaf 1
  printf "PPA's going to be removed\n%s\n" "$(cat /tmp/awk2.txt)"
  tput sgr0
  while read -r line; do echo "sudo add-apt-repository -r ppa:$line"; done < /tmp/awk2.txt > out
  bash out
else
  tput setaf 1
  echo "No PPA's to be removed"
  tput sgr0
fi

Give execute permission to the script

sudo chmod +x ppa-remove

Copy and paste the ppa-remove file into /usr/bin directory.So that you can access it from anywhere.

Usage

sudo ppa-remove

Script Description

[ -f /tmp/update.txt ] && sudo rm /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait" || echo "No update file"

tput setaf 6 command turns the terminal text colour into green.And then it displays "Initializing ..Please Wait" in green colour.

sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; uniq /tmp/awk1.txt > /tmp/awk2.txt
  1. sudo apt-get update >> /tmp/update.txt 2>&1;

    Both stdout and stderr of the command sudo apt-get update are written to the file /tmp/update.txt

  2. awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt;

Awk searches for the line which consists of W:,launchpad,404 in the /tmp/update.txt file.If it found that then in that line it displays(stdout) all the letters starting from the 26th location in column5.This standard output was redirected(written) to the /tmp/awk.txtfile.

For example:

W: Failed to fetch http://ppa.launchpad.net/pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages  404  Not Found

5th coloumn - http://ppa.launchpad.net/pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages

in that 5th column start from 26th character- pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages

This above line was stored into /tmp/awk.txt file.Now the next command,

awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt;  

awk findout out the column1 and column2 with the delimiter / where the column1 and column2 are concatenated by /from the /tmp/awk.txt file and then redirects(written) the stdout to /tmp/awk1.txt file.

Now /tmp/awk1.txt file contains pitti/postgresql line.

uniq /tmp/awk1.txt > /tmp/awk2.txt

If there are two same lines, unique command displays(stdout) single line only.That single line was written to /tmp/awk2.txt Finally /tmp/awk2.txt consists of unique PPA names.

tput sgr0

This command changes the colour of terminal text into white.

Finally if conditional statements will executes. if [ -s /tmp/awk2.txt ] check for the contents of /tmp/awk2.txt file presents or not.If yes, then it takes the first line from /tmp/awk2.txt and executes sudo add-apt-repository -r ppa:$line command.It continues upto to the last line.

If no, it means there is no contents.So it says "No PPA's to be removed".

Screenshots

enter image description here

enter image description here

  • /usr/bin/ppa-remove: line 32: syntax error: unexpected end of file – Shravan40 Feb 14 '16 at 19:31

You are getting these errors because your PPA repositories don't provide packages for your distribution of Ubuntu (ie; quantal).

Look at the following screenshots:

ppa:petrakis/wdt-main Launchpad logo

wdt-main

ppa:screenlets/ppa Launchpad logo

screenlets

You can see that the directory for quantal is missing and hence you are getting 404 Not Found Error Messages.

To get rid of these messages you have to remove these PPA repositories from your system. Follow this question on how to remove PPAs:


How to investigate this and come to this conclusion?

These are the error messages you receive for wdt-main PPA:

W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/source/Sources  404  Not Found
, W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/binary-amd64/Packages  404  Not Found
, W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/binary-i386/Packages  404  Not Found

Open your browser tab and open the link which gives 404 Not Found Errors. In this case http://ppa.launchpad.net/petrakis/ and go deeper as per the link which gives errors. You would be able to see what the actual problem is.

The most probable that it's happening is that the PPA is not longer maintained and needs to be removed. You can do this just using:

sudo rm /etc/apt/sources.list.d/ppaname-ppa-$(lsb_release -sc).list*
  • 3
    this just saved a duplicate question from being posted.. I had the body of my Q ready and just as I started to type my title found the link.. why don't they keep all the list at a place! there are some listed in /etc/apt/sources.list where I did check but didn't know I had to look in /etc/apt/sources.list.d/ too.. thanks.. – precise Mar 12 '14 at 11:15
  • this and then adding the proper new PPA turned out to be the best (only working) solution for me. – markus-tharkun Mar 3 '16 at 12:59

Choose Older Repository

If you're really need the packages from that repository, you can use the mirrors from older release.

However, please note that not all older releases are backward compatible; some of them causes conflicts with your main package repository.

The only thing you can do when it conflicts is either building from source or wait until the provider releases the repository for your Ubuntu version. We don't know exactly when the package providers will release their package for our version, so you're the one in charge to check their repository for your release.

This can be used with any Debian-based repository. However, there is no guarantee that this will be successful.

Steps

  1. Do usual sudo apt update after adding PPA/repository. You can notice that there are 404 errors while updating; just ignore this. 404 Error
  2. Open the repository directory which causes 404 error with your browser; in this case it is https://dl.winehq.org/wine-builds/ubuntu. Usually, available releases are located in dists/. Mirrors
  3. After you located it, open Software & Updates, and replace your release name with the available release; preferably latest or LTS one. Replace 'Distribution' section in binary and source code mirrors. In this case, I'm replacing bionic with artful. enter image description here
  4. Do sudo apt update again.
  5. You're done! Now you have no more 404 errors while updating your package lists. enter image description here
  6. When the packages for your Ubuntu version is released, repeat step 3 and 4 by replacing 'Distribution' section with your distribution name.

Note that it already happened to me and I was out of these situations. And it also worked for a friend of mine. Even not being able to explain why, there is something that solved that problem:

  1. Disable all your PPAs;
  2. Run sudo apt-get update from terminal;
  3. Enable your PPAs back again;
  4. Run sudo apt-get update;

And suddenly it worked. Do not ask me why.

  • Made no difference for me. Still 404s. – kwoxer Jan 6 '16 at 7:56
  • I disabled some of unwanted PPAs and tried sudo apt-get update and its worked perfectly. – Shashanth Jun 7 '17 at 6:56

If you are getting a 404 error trying to obtain security or system files from an official repository (not a PPA) you can chose a different mirror to resolve this issue.

You can either:

A) determine one Manually by reviewing this list and choosing the most current mirror. (you may wish to take into consideration other factors such as distance and bandwidth) or

B) Choose one automatically.

Either way you can start with the Software & Updates application as shown below: Then Select Download from followed by Other. Then you can either manually choose the mirror of your choice from the list or click the Select best Server button which will run some tests and choose the best server for you dependent on current conditions.

SnU

I have tried every possible answer, but the only solution was to copy the Ubuntu 16.04 Xenial default /etc/apt/sources.list file to my /etc/apt/sources.list.

Sources: https://gist.github.com/rohitrawat/60a04e6ebe4a9ec1203eac3a11d4afc1

That saved my Linux.

protected by jokerdino Feb 20 '13 at 3:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.