apt-cacher-ng: a package cache for several Ubuntu and Debian machines

If you run several Ubuntu or Debian systems – VMs and containers on a Proxmox server, say, or a few Raspberry Pis – you download the same packages several times with every update. apt-cacher-ng is a cache for exactly that: the first system downloads a package from the internet, all the others get it from the cache at LAN speed.

Setting up the server

On the machine that is to act as the cache (e.g. a small container):

sudo apt install apt-cacher-ng

That is all it takes – the service listens on port 3142 right away. The cached packages are stored in /var/cache/apt-cacher-ng; make sure there is enough space (a few GB). A statistics page is available at http://SERVER:3142/acng-report.html.

Setting up the clients

Create a proxy file on every client (adjust the IP address of the cache server):

echo 'Acquire::http::Proxy "http://192.168.178.40:3142";' | sudo tee /etc/apt/apt.conf.d/01proxy
sudo apt update

From the next apt update on, requests go through the cache. Whether it works is shown by the statistics page or by the log on the server: tail -f /var/log/apt-cacher-ng/apt-cacher.log.

Automatic discovery

Instead of hard-coding the address, the auto-apt-proxy package can find the cache by itself. Among other things, it checks whether an apt-cacher-ng is reachable on the gateway or under the name apt-proxy and then uses it – if it is not reachable, packages are downloaded directly. Ideal for laptops that are not always on the home network.

sudo apt install auto-apt-proxy

What about HTTPS repositories?

The official Ubuntu and Debian mirrors are accessed via HTTP – the packages are GPG-signed, so this is safe – and are cached. Third-party sources using https:// (e.g. Docker, Grafana) bypass the cache with the setting above and go straight to the internet, because the proxy is only set for http. This works without problems; those packages are simply not cached.

Cleaning up the cache

apt-cacher-ng removes packages that are no longer needed by itself every day. The maintenance can also be triggered manually from the statistics page (“Expiration” section).

Originally published in 2012, completely revised in November 2026.