Setting up an ‘Apt-Cache’ Server Using ‘Apt-Cacher-NG’ in Ubuntu 14.04 Server

Apt-Cacher-NG is a caching proxy server (or apt proxy) for Debian based distributions like Ubuntu, Kubuntu, Xubuntu, Edubuntu, Linux Mint, etc, which is used to cache the downloaded packages locally on your server.

Apt Cache for Ubuntu
Install Apt-Cacher-NG in Ubuntu 14.04

Let’s say you having a small network with few computers attached it and you want to install and update software packages on each system manually, then it would be difficult task and time consuming, that’s the reason configuring an apt-cacher-ng on any system would be great idea, because it will first caches all the downloaded packages from the internet on the apt-cache server and the rest of the Debian, Ubuntu machines get them from Apt-Cache, this will save our precious time and internet bandwidth too.


  1. apt-cacher-ng will save our time.
  2. apt-cacher-ng will save our bandwidth.
  3. We can integrate ISO image data or DVD to apt-cacher-ng using import option.

Here I’m going to setup a cache server in Ubuntu 14.04. In our office we use more than 30 Ubuntu Desktop clients, 28 Ubuntu-Server VMS’s including 12.04 & 14.04, 4 Linux mint Desktop. But we use a single cache server which runs in Ubuntu 12.04 LTS Server Edition. And until now there’s nothing conflict with the packages. Now let us start setting up apt-cache server.

Note: This is not an Ubuntu or Debian Mirror, this is just a cache server for apt packages.

My Server Setup
Apt Cache Server OS   : Ubuntu 14.04 LTS Server
Apt Cache IP Address  :
Apt Cache Hostname    : aptcacher.tecmint.lan
Default Port	      : 3142
My Client Setup
Client OS             : Ubuntu 14.04 LTS
Client IP Address     :
Client Hostname       : client.tecmint.lan

Step 1: Installing and Configuring Apt-Cacher-NG on Server

First, login into server to open a terminal using ‘Ctr+Alt+T‘ and install Apt-Cacher-NG package using following ‘apt’ command.

$ sudo apt-get install apt-cacher-ng
Install apt-cacher-ng in Ubuntu
Install apt-cacher-ng in Ubuntu

After installation completes, the apt-cacher-ng will start automatically. Now open and edit the cache-ng configuration file located under ‘/etc/apt-cacher-ng‘ directory.

$ sudo vim /etc/apt-cacher-ng/acng.conf
Open Apt Cache Configuration File
Open Apt Cache Configuration File

Next, we need to uncomment the following lines as suggested, if its commented remove the ‘#‘ from the beginning. In this directory all dpkg package will be stored while installing or updating package’s.

CacheDir: /var/cache/apt-cacher-ng

To Enable the log we need to enable this line, By Default it will be enabled.

LogDir: /var/log/apt-cacher-ng

Apt-cacher will listen to the port 3142, if you need to change the port, you can change the port.

Configure Apt-Cacher-Ng
Configure Apt Cacher

Next, add the line ‘BindAddress:’ entry below the line says:

# BindAddress: localhost publicNameOnMainInterface
Add Bind Address
Add Bind Address

Here we can define the distributions such as Ubuntu and Debian, which all need to be cached.

Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
Cache Packages Locally in Ubuntu
Cache Packages Locally

If we need to get the reports of apt-cache in web interface, we need to enable the following line, but by default this will be enabled.

ReportPage: acng-report.html
Enable Apt Cache Reports
Enable Apt Cache Reports

To get more information about ‘log‘, we have to uncomment the below line, If we set it to 0 Only activity type, time, size of our packages transfer will be logged.

VerboseLog: 1
Log Apt Cache Information
Log Apt Cache Information

To run the apt-cacher service, we need to enable the pid file in the configuration.

PidFile: /var/run/apt-cacher-ng/pid
Enable Apt Cache Service
Enable Apt Cache Service

To remove the unreferenced files.

ExTreshold: 4
Remove Unreferenced Files
Remove Unreferenced Files

Finally, we’ve done with the configuration, save and close the file. Now we all set to restart the apt-cacher-ng service using following command.

$ sudo /etc/init.d/apt-cacher-ng restart
Start Apt Cache Service
Start Apt Cache Service

Access the report page of apt-cacher-ng in web interface using below URL.
Apt Cache Access Reports
Access Reports
Apt Cache Transfer Statistics
Transfer Statistics

Here we can see the report page for apt-cacher-ng, Click the static report and configuration page at the bottom of this page to get the Download hits and misses.

From the report home page we need to copy the Proxy URL for later use. We can even install packages in this server from apt-cache which can be configured locally, by just adding below entry in /etc/apt/apt.conf.d/02proxy.

Acquire::http { Proxy ""; };

Step 2: Client Side Configuration

First login into client machine (Ubuntu/Debain) and create a ’02proxy’ file under ‘/etc/apt/apt.conf.d/’ directory.

$ sudo vim /etc/apt/apt.conf.d/02proxy
Create Apt Proxy File
Create Apt Proxy File

Now Copy the Acquire URL and append to the 02proxy file. You will get the following URL from the apt-cacher-ng access report page at

Acquire::http { Proxy ""; };
Add Apt Proxy Repo
Add Apt Proxy Repo

Save and exit using wq!. Hereon, if any packages are downloaded on the client machine will be cached to apt-cache server.

In my client machine 92 packages can be updated, 43 updates are security updates which is available. We have already applied the same updates for cache server. So, that the packages will now be cached in apt-cacher. If I’m updating this client machine it won’t take too much time to get packages from internet.

Package Update Info
Package Update Info

Now update the repository and upgrade the packages.

$ sudo apt-get update 
$ sudo apt-get upgrade
Update Packages Locally in Ubuntu
Update Packages Locally
Upgrade Packages Locally in Ubuntu
Upgrade Packages Locally

In the above screens, it shows that we need to update 85 packages and its size is 104MB, let us see how long it will take to fetch the package.

I’m not even in a data centre, I’m just using a 256Kbps internet connection where the download speed will just be 50Kbps to 60Kbps. But see the below image how it fetched 104MB in 3 Seconds? That’s because it is already cached in apt-cacher-ng server.

Apt Cacher NG Speed
Apt Cache Download Speed

If we need to see Cache Count data, which we have downloaded, we can access ip:port ( in any web browser to see the statistics, like I have explained above.

Apt Cacher NG Statistics
Apt Cacher NG Statistics

While, we downloads any packages to install in any Debian/Ubuntu machines, If the package is available in apt-cache it will get from the apt-cache-ng server, if not it will fetched from internet to local repository for future use.

In this article, we have seen how to setup a local cache server for apt packages using apt-cacher-ng, many people wants this setup to save their time and bandwidth. I hope this will helps for all those who use Debian/Ubuntu machines.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Babin Lonston
I'm Working as a System Administrator for last 10 year's with 4 years experience with Linux Distributions, fall in love with text based operating systems.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

23 thoughts on “Setting up an ‘Apt-Cache’ Server Using ‘Apt-Cacher-NG’ in Ubuntu 14.04 Server”

  1. i want for my ISP will this work for my large network? my server specification will be 40tb hard-disk with 1tb ssd drive.

  2. What if i wanted to fetch the package from another mirror which isn’t in the sources.list file of APT? Will APT-cacher-ng will cache that package too??

    If not, is it possible to configure apt-cacher-ng to cache exterior repositories?

    • @Utkarsh,

      Yes, you can add any repository URL to sources.list moreover even you are allowed to use PPA repo, the same PPA repo need to be installed in all clients.

      Thanks & Regards,
      Bobin Lonston

  3. good article. Its very helpful to reduce bandwidth.

    There is one question, if local server not connected it should get from internet. how we can resolve this issue.

  4. Hi,
    how a nice article.
    I think this is very useful to install a cache machine and I’m researching the cache server recently,

    May I cite this article to my academic research?


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.