Ubuntu – Apt-Get using Apt-Cacher NG fails to fetch packages with hash sum mismatch

aptapt-cacher-ngnetworking

I have a machine who is using Apt-Cacher NG running on another machine as caching proxy.

When I try to run sudo apt-get update I get the following errors:

W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_source_Sources  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_universe_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-i386_Packages  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

The directory /etc/apt/sources.list.d is empty.

To fix that I have already tried the following with no success:

Solution 1:

sudo rm -fr /var/lib/apt/lists
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get autoclean

Solution 2:

sudo apt-get update -o Acquire::http::No-Cache=True

Any suggestion?

Best Answer

I would suggest to switch away from APT-cacher-ng and check out Squid-deb-proxy.

APT-cacher-ng has proven to be very buggy in my experience and tons of bug reports are outstanding. Only recently it has been proposed again to get unblocked in Debian now that some major bugs are squashed. For Ubuntu I've switched to Squid-deb-proxy a long time ago and I don't regret it. It's a great alternative and the best APT-cacher I've come around.

For Squid-deb-proxy, just install the package squid-deb-proxy and add allowed destination domains in a new file in /etc/squid-deb-proxy/mirror-dstdomain.acl.d. As a bonus, clients can auto-discover caching-enabled machines in the local network by having the squid-deb-proxy-client package installed.

Related Question