After discovering an old server that was still running Ubuntu 11.10 I found that apt-get was no longer working as support for this version ended 9 months after it was released, quite some time ago!
I was seeing errors from apt-get update like:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/main/source/Sources 404 Not Found
And errors from apt-get upgrade like:
Err http://archive.ubuntu.com/ubuntu/ oneiric-updates/main ncurses-bin i386 5.9-1ubuntu5.1
403 Forbidden
Since the server isn't quite ready to be replaced I had to find a temporary solution.
Luckily ubuntu provides a repository for old releases, aptly named old-releases.ubuntu.com.
To use it, open /etc/apt/sources.list with your favourite text editor (you'll need to be root or use sudo) and replace all occurrences of archive.ubuntu.com or security.ubuntu.com with old-releases.ubuntu.com.
My sources.list now looks like this:
deb http://old-releases.ubuntu.com/ubuntu/ oneiric main
deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric main
deb http://old-releases.ubuntu.com/ubuntu/ oneiric-updates main
deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric-updates main
deb http://old-releases.ubuntu.com/ubuntu/ oneiric universe
deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric universe
deb http://old-releases.ubuntu.com/ubuntu/ oneiric-updates universe
deb-src http://old-releases.ubuntu.com/ubuntu/ oneiric-updates universe
deb http://old-releases.ubuntu.com/ubuntu oneiric-security main
deb-src http://old-releases.ubuntu.com/ubuntu oneiric-security main
deb http://old-releases.ubuntu.com/ubuntu oneiric-security universe
deb-src http://old-releases.ubuntu.com/ubuntu oneiric-security universe
After you have updated the sources run an update:
$ sudo apt-get update
If you're still getting any 404 or 403 errors then double check your sources are correct. Otherwise you should now be able to upgrade your packages:
$ sudo apt-get upgrade
The above solution should work for Ubuntu releases as old as 4.10 (warty), though I haven't tested this.
You can avoid this problem in the future by using only LTS (long term support) releases which are supported for 5 years.
Thank you!! I spent the past hour trying to get my oneiric instance to install python-dev. The 403 Forbidden errors were driving me crazy!