How to Add an APT Repository Proxy in Ubuntu? [Easiest Guide]

A well-functioning system in the world of Debian-based Linux distros such as Ubuntu demands effective and seamless software package management. The repository proxy can be a handy tool in ensuring network efficacy and curtailing the load on the external repository. Therefore, in this article, I will lead you through the procedures of how to add an apt repository proxy in your Ubuntu environment.

Key Takeaways

  • Getting Acquainted with the Repository Proxy in Ubuntu.
  • Learning to Add and Configure the Repository Proxy in Ubuntu.


Process Flow Chart

[Distro Used Throughout the Tutorial: Ubuntu 22.04]the add apt repository proxy flowchart

What is an APT Repository Proxy in Ubuntu?

The APT (Advanced Package Tool) repository proxy is a server or software configuration acting as the intermediary between the user system Ubuntu and the official package repositories. The fundamental goal of an Ubuntu repository proxy is to elevate network effectiveness, reduce bandwidth usage, and accelerate package management for a smooth interaction with software.

The Benefits of the  APT Repository Proxy in Ubuntu

The apt repository proxy provides Ubuntu practitioners with several advantages in terms of package handling and some of the essential ones are mentioned below:

  1. Bandwidth Optimization: The repository proxy handles package management through a local cache and this, in turn, reduces the external bandwidth consumption.
  2. Load Balancing on External Repositories: The proxy server stores the frequently accessed packages in its local storage. As a result, the package request from the user end is processed via proxy and it balances the repeated need of external repositories.
  3. Quick Retrieval of Packages: Since the download of packages is not done from the main remote repositories during the use of a repository proxy, the fetching of software packages becomes faster.
  4. Offline Access: The proxy server operates using a local cache. Hence, the downloading, installing, and updation of software packages are served even in isolated environments without rigorous efforts.

Easiest Process to Add an APT Repository Proxy Server in Ubuntu

In this feature, I will discuss how to add the repository proxy in Ubuntu to boost your package management experience. Specifically, I will cover the CLI (Command Line Interface) based method for this phenomenon that demands just a few easy steps along with executing effortless commands.

Steps to Follow >

➊ At first, open your Ubuntu terminal. [Shortcut: CTRL+ALT+T]

➋ Secondly, type the following command and hit the ENTER button.

sudo nano /etc/apt/apt.conf.d/proxy.conf
  • sudo: Grants sudo privileges.
  • nano: Used to open the nano text editor in the command line.
  • /etc/apt/apt.conf.d: The subdirectory containing the configuration file.
  • proxy.conf: File used to configure the proxy settings for apt.

➌ Now, enter the following lines to the file to add the repository proxy.

Acquire:: http::Proxy “http://<proxy server ip address>:<proxy-port>”

adding proxy server address and port to add apt repository proxySo, in the image above, you spot that I have added a proxy server IP address and port number for configuration.

➍ After that, press CTRL+S to save and CTRL+X afterward to exit the file.

➎ At this point, run the below-mentioned command to update the system cache.

sudo apt update
  • sudo: Grants root privileges.
  • apt: The package management tool.
  • update: Action updating the system repository index.

updating the system after adding proxy serverHere, you see that I have run the above command to update my system repository index. Also, the proxy settings will be enabled the next time I run anything related to APT.  For instance, I will install a package namely net-tools and the system will use the repository proxy server for this purpose.

➏ Now, type the below command and press Enter to install net-tools from the proxy server.

sudo apt install net-tools
  • sudo: Grants sudo privileges.
  • apt: The package management tool.
  • install: The apt subcommand for package installation.
  • net-tools: Name of the package to be installed.

net tools package installation using proxy serverIn the above snap, I have displayed the installation of the net-tools package. Due to the earlier configuration, the repository proxy server maintains the package handling.

Complementary Information to ADD APT Repository Proxy in Ubuntu

The add-apt-repository is the fundamental command in terms of apt repository management. Now, sometimes it may hang during execution due to its inability to connect to the external repository server. However, this is seamlessly resolved by adding the repository proxy in your Ubuntu system which is also the agenda of the following section.

Configure APT Proxy to Resolve “sudo add-apt-repository” Hanging Issue in Ubuntu

As I said earlier, you can configure the apt repository proxy to yield the solution to the connectivity issue. This, in consequence, solves the hanging issue of running the add-apt-repository command smoothly and serving your software package management needs. Therefore, I will now attach the necessary steps below.

Steps to Follow >

➊ First, press CTRL+ALT+T to access the command prompt.

➋ Now, run the below command to open the APT configuration file.

sudo nano /etc/apt/apt.conf.d/proxy.conf

➌ After that, add the following lines.

Acquire:: http::Proxy “http://<proxy server ip address>:<proxy-port>”

Acquire:: https::Proxy “http://<proxy server ip address>:<proxy-port>”
Note: Replace the proxy server IP address and proxy port with your actual proxy server address and port.

adding proxy server IP and port address for resolving hanging issueIn the image snapshot, you can discern I have added the proxy server IP address and port number in the configuration file.

➍ At this point, press CTRL+S to save and then CTRL+X to exit.

Finally, this will allow APT to work behind the proxy server and resolve the hanging issue.


In this article, I have walked you through the concepts of the repository proxy in Ubuntu along with mentioning practical illustrations. I hope this will be enough to get started with proxy server configuration and make you a proud member of the Linux power user community.

People Also Ask

Is the apt repository proxy useful in Ubuntu?
The apt repository proxy is useful because it enhances the package management system’s efficiency, speed, and security for Ubuntu and other Debian-based Linux distributions. 
Which proxy server software is commonly used for Ubuntu repository proxies?
The squid server is a popular choice for creating an Ubuntu repository proxy since it can efficiently cache and distribute packages from Ubuntu repositories to client systems. 
Where is the apt repository list in Ubuntu?
The apt repositories in Ubuntu are primarily located in the /etc/apt/sources.list.d/ directory. This directory contains the repository configuration file sources.list.
What is the purpose of the repository proxy in Ubuntu?
The repository proxy serves as an intermediary server to cache Ubuntu software packages and updates to reduce the load of the external repositories. 

Related Articles

<< Go Back to Repository Configuration in Linux | Package Management in Linux | Learn Linux Basics

4.7/5 - (8 votes)
Md Masrur Ul Alam

Assalamu Alaikum, I’m Md Masrur Ul Alam, currently working as a Linux OS Content Developer Executive at SOFTEKO. I completed my Bachelor's degree in Electronics and Communication Engineering (ECE)from Khulna University of Engineering & Technology (KUET). With an inquisitive mind, I have always had a keen eye for Science and Technolgy based research and education. I strongly hope this entity leverages the success of my effort in developing engaging yet seasoned content on Linux and contributing to the wealth of technical knowledge. Read Full Bio

Leave a Comment