Atlantic.Net Blog

How to Set up APT-Caching Server Using Apt-Cacher NG on Ubuntu 20.04

Hitesh Jethva
by Atlantic.Net (429 posts) under Tutorials, VPS Hosting

Apt-Cacher NG is a caching proxy server for Debian-based Linux distributions including Ubuntu, Debian, Linux Mint, etc. It creates a local cache of the Debian mirrors and other Linux distributions. When you use the apt command to install any package, the package is pulled from the official repositories, and the APT cache server caches that package in the system. When you install the same package again, it will download that package from the local caching server. This will save you a lot of time and internet bandwidth.

In this post, we will explain how to set up an APT-Caching server using Apt-Cacher NG on Ubuntu 20.04.


  • Two servers running Ubuntu 20.04 on the Atlantic.Net Cloud Platform
  • A root password configured on both servers

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Ubuntu 20.04 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install Apt-Cacher-NG

By default, the Apt-Cacher-NG package is included in the Ubuntu default repository. You can install it using the following command:

apt-get install apt-cacher-ng -y

Once the Apt-Cacher-NG package is installed, start the Apt-Cacher-NG service and enable it to start at system reboot:

systemctl start apt-cacher-ng
systemctl enable apt-cacher-ng

You can check the status of Apt-Cacher-NG with the following command:

systemctl status apt-cacher-ng

Sample output:

● apt-cacher-ng.service - Apt-Cacher NG software download proxy
     Loaded: loaded (/lib/systemd/system/apt-cacher-ng.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-08-15 07:13:14 UTC; 20s ago
   Main PID: 3748 (apt-cacher-ng)
      Tasks: 1 (limit: 2353)
     Memory: 2.0M
     CGroup: /system.slice/apt-cacher-ng.service
             └─3748 /usr/sbin/apt-cacher-ng -c /etc/apt-cacher-ng ForeGround=1

Aug 15 07:13:13 ubuntu2004 systemd[1]: Starting Apt-Cacher NG software download proxy...
Aug 15 07:13:14 ubuntu2004 systemd[1]: Started Apt-Cacher NG software download proxy.

By default, Apt-Cacher-NG listens on port 3142. You can check it with the following command:

ss -altnp | grep apt

Sample output:

LISTEN    0         250         *        users:(("apt-cacher-ng",pid=3748,fd=10))                                       
LISTEN    0         250                   [::]:3142                [::]:*        users:(("apt-cacher-ng",pid=3748,fd=11))                                       

Step 3 – Configure Apt-Cacher-NG

By default, Apt-Cacher NG does not serve HTTPS repositories, so you will need to enable it. To do so edit the Apt-Cacher-NG default configuration file:

nano /etc/apt-cacher-ng/acng.conf

Uncomment the following line:

PassThroughPattern: .*

Save and close the file, then restart the Apt-Cacher-NG service to apply the changes:

systemctl restart apt-cacher-ng

Step 4 – Configure Client System to use Apt-Cacher NG

By default, all Ubuntu system uses Ubuntu repository to download and install packages, so you will need to configure your client system to use Apt-Cacher NG for package installation.

To do so, create a new proxy configuration file:

nano /etc/apt/apt.conf.d/00aptproxy

Add the following line:

Acquire::http::Proxy "http://your-server-ip:3142";

Save and close the file when you are finished.

Step 5 – Verify APT-Cacher NG

Now, let’s try to install the Apache package on the Client system using the following command:

apt-get install apache2 -y

The above command will find, download, and install an Apache package from the Apt-Cache NG server.

You can check it using the following command on the server system:

tail -f /var/log/apt-cacher-ng/apt-cacher.log

Sample output:


Apt-Cache NG also provides a web-based interface to display all reports. You can access it using the URL
http://your-server-ip:3142/acng-report.html. You should see the following screen:
APT-Cache NG Dashboard Page

Step 6 – Control Apt-Cacher NG Usage

You can also set up access control for Apt-Cache NG so that only authenticated hosts can download the package from the Apt-Cacher NG server.

You can use the /etc/hosts.allow and /etc/hosts.deny for controling access.

For example, to allow and to use Apt-Cacher NG server, edit the /etc/hosts.allow file:

nano /etc/hosts.allow

Add the following line:

apt-cacher-ng :

Save and close the file when you are finished.

If you want to block the host to use Apt-Cacher NG server, edit the /etc/hosts.deny file:

nano /etc/hosts.deny

Add the following line:

apt-cacher-ng :

Save and close the file when you are finished.


In the above guide, we explained how to install and use Apt-Cache NG server on Ubuntu 20.04 server. You can now set up Apt-Cache NG in your local network to save a lot of internet bandwidth – try it on VPS hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Sails.js Framework with Nginx on Oracle Linux 8
How to Install OTRS on Oracle Linux 8
How to Install and Configure Caddy Web Server with PHP on Oracle Linux 8
How to Install and Use PIP Python Package Manager on Oracle Linux 8
How to Install FTP Server with ProFTPD on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom