Support #198

Installing apt-cacher-ng on Debian

Added by Daniel Curtis about 8 years ago. Updated almost 7 years ago.

Automated Server Management
Target version:
Start date:
Due date:
% Done:


Estimated time:
1.50 h
Spent time:


During the expansion of the ALT VPS Infrastructure, I needed a place to store and cache packages for the servers in the ALT DMZ network. This would increase overall performance by caching updates and installed packages on the APT caching server and serving them to the local nodes in the ALT DMZ network. Creating new virtual servers will also see a boost in speed, since bootstrapping a newly created virtual server will pull from the APT caching server instead of having to download the packages from the Internet.

  • Install apt-cacher-ng on the caching server
    sudo apt-get install apt-cacher-ng

Once the package is finished installing, open a web browser and go to
This will bring you to a page displaying:

You attempted to browse the contents of a virtual HTTP repository. However, the intended way of use is the configuration of APT and related package management systems to retrieve the software packages through this service.

To configure APT for use of Apt-Cacher NG you need to...

EITHER: Configure APT to use a HTTP proxy by specifying it in apt.conf or related configuration files, see apt.conf manual page for details. Server and Port need to match the values used to visit this page. For example, edit /etc/apt/apt.conf and add the line:

Acquire::http { Proxy ""; };

OR: Edit the /etc/apt/sources.list file and edit the source lines therein, replacing the mirror hostname with the hostname of this server machine and the port with 3142 (adding a port if none specified). For example:

deb stable main contrib non-free
deb-src stable main contrib non-free


deb stable main contrib non-free
deb-src stable main contrib non-free

Depending on the configuration, it might be possible to use a shortcut for the base URLs without knowing the mirror, for example:

deb stable main contrib non-free

Ask your system administrator for details.

  • This means the installation succeeded and hosts can now be pointed to the APT caching server by adding the following to the clients /etc/apt/sources.list:
    deb stable main contrib non-free
  • Then refresh the repository information of the client:
    sudo apt-get update

Importing existing package archive

  • If there are already packages installed on the client, they can be copied into apt-cacher-ng by:
    sudo mkdir /var/cache/apt-cacher-ng/_import
    sudo cp /var/cache/apt/archives/* /var/cache/apt-cacher-ng/_import/
    sudo chown -R apt-cacher-ng /var/cache/apt-cacher-ng/_import

    And then open the web configuration and go to the Statistics report and configuration page, then click [Start Import]

Updated by Daniel Curtis almost 7 years ago

  • Description updated (diff)

Updated by Daniel Curtis almost 7 years ago

  • Project changed from 46 to GNU/Linux Administration
  • Category set to Automated Server Management

Also available in: Atom PDF