How do I configure proxy settings for apt?

Published on Aug. 22, 2023, 12:18 p.m.

To configure proxy settings for apt, you can create a configuration file called /etc/apt/apt.conf.d/proxy.conf with the necessary information. Here are the steps:

  1. Open your terminal and create a new file called proxy.conf within the /etc/apt/apt.conf.d/ directory using the following command:
sudo nano /etc/apt/apt.conf.d/proxy.conf
  1. Add the following lines of code to the proxy.conf file, replacing <your-proxy-server> and <your-proxy-port> with the correct values:
Acquire::http::proxy "http://<your-proxy-server>:<your-proxy-port>/";
Acquire::https::proxy "http://<your-proxy-server>:<your-proxy-port>/";
  1. Save the file and exit nano.
  2. Test the proxy configuration by running the following command within your terminal:
sudo apt update

If the configuration is correct and the proxy server is available, you should be able to update your apt repositories without any issues.

Note that if your proxy server requires a username and password, you should add the following lines to the proxy.conf file, replacing <your-username> and <your-password> with the correct values:

Acquire::http::proxy "http://<your-username>:<your-password>@<your-proxy-server>:<your-proxy-port>/";
Acquire::https::proxy "http://<your-username>:<your-password>@<your-proxy-server>:<your-proxy-port>/";

I hope that helps! Let me know if you have any further questions.

Tags: