Tuesday 31 May 2011

FIX: 404 Errors Using apt-cacher-ng

I recently upgraded my Ubuntu server to Debian Squeeze, but not without difficulties.

The first problem was with apt-cacher-ng. Well, actually it was two problems. The first involves an apparent difference between how Ubuntu and Debian configure their apt clients to use a proxy.

On Ubuntu I have always used /etc/apt/apt.conf with a single line pointing to my proxy like so;

Acquire::http { Proxy "http://apt:3142"; };

This didn't seem to work with Debian clients, the fix is to put the same line into a file at /etc/apt/apt.conf.d/01proxy.

Actually you can call the file anything you like, even "apt.conf" but naming the file like this fits in with normal Debian conventions better, which can't be a bad thing.

The second issue I had was with Ubuntu clients using the apt-cacher-ng proxy installed on a Debian server.

I kept getting "404 Not Found" errors every time I did an apt-get update on the (lucid) clients.

Google was no help. There were a few people who were having the same problem but no answers.

Eventually I found the issue myself. There is a file in the apt-cacher-ng directory that has an error. To fix the problem you edit this file;

vi /etc/apt-cacher-ng/backends_ubuntu

and change the line so it says something like this;

http://au.archive.ubuntu.com/ubuntu/

Of course you should change it to something more local to where you are. The key here is that on my system the trailing /ubuntu/ was missing and this was causing the 404 errors.

4 comments:

dfsmith said...

Thanks---worked for me.
Upgraded Debian Lenny->Squeeze on my back-end cache server.
The backends_ubuntu file was empty: putting in the suggestion above (localized for the US archive) worked.

Mark said...

This worked for me too, my backend_ubuntu file (running Squeeze) was also empty

pepe.jose said...

thanks, this solved my problem on my apt-cache-ng server on debian for my ubuntu clients

wobblybob9 said...

You are a Star, it's taken me hours to try and solve this problem with apt-cacher-ng on my newly installed Debian Squeeze. The backends file was indeed empty and once I corrected this all is well. Thanks again
wobblybob9