How to fix E: Could not connect to proxy server in APT

APTINTERMEDIATEMEDIUMUpdated Dec 29, 2025ยท 149 views

This error occurs when apt cannot establish a connection to a configured proxy server. Common causes include incorrect proxy configuration, unreachable proxy server, wrong credentials, or firewall blocking.

Quick fix

Fixes E: Could not connect to proxy server

sudo cat /etc/apt/apt.conf
sudo cat /etc/apt/apt.conf.d/proxy.conf
cat ~/.bashrc | grep -i proxy
cat /etc/environment | grep -i proxy
  1. Verify proxy configuration files
  2. Test proxy server connectivity
  3. Verify proxy credentials if required
  4. Bypass proxy temporarily to test
apt โ€” error
sudo cat /etc/apt/apt.conf
sudo cat /etc/apt/apt.conf.d/proxy.conf
cat ~/.bashrc | grep -i proxy
cat /etc/environment | grep -i proxy
E: Could not connect to proxy server

What this error means

The apt package manager has been configured to use a proxy server for downloading packages, but it cannot establish a connection to that proxy. This typically indicates a network connectivity issue between your system and the proxy server, misconfiguration in apt settings, or the proxy server being offline.

Typical symptoms

  • apt update or apt install commands fail with connection errors
  • Error message shows specific IP address and port that cannot be reached
  • Other applications can connect to the internet but apt cannot
  • Proxy configuration exists in /etc/apt/apt.conf or environment variables

Common causes

  1. Incorrect proxy server address or port in apt configuration
  2. Proxy server is offline or unreachable on the network
  3. Firewall rules blocking connection to the proxy server
  4. Incorrect username or password for proxy authentication
  5. Proxy server requires credentials but none are provided
  6. Network connectivity issues between client and proxy
  7. Special characters in proxy credentials not properly URL-encoded

How to fix "E: Could not connect to proxy server"

1Verify proxy configuration files

Check if apt is configured to use a proxy by examining these files:

bash
sudo cat /etc/apt/apt.conf
sudo cat /etc/apt/apt.conf.d/proxy.conf
cat ~/.bashrc | grep -i proxy
cat /etc/environment | grep -i proxy

Look for lines like:

bash
Acquire::http::Proxy "http://proxy:port";
Acquire::https::Proxy "https://proxy:port";
http_proxy=http://proxy:port
2Test proxy server connectivity

Verify the proxy server is reachable using telnet or nc:

bash
telnet proxy.example.com 8080

Or using nc:

bash
nc -zv proxy.example.com 8080

A successful connection shows no error message. If connection is refused, the proxy is not accessible.

3Verify proxy credentials if required

If your proxy requires authentication, ensure credentials are properly configured. Special characters in passwords must be URL-encoded:

bash
# Example with credentials:
Acquire::http::Proxy "http://username:password@proxy.example.com:8080/";

For special characters like @ or !, use URL encoding:
- @ becomes %40
- ! becomes %21
- $ becomes %24

Test the proxy directly:

bash
curl -x http://username:password@proxy:port http://example.com
4Bypass proxy temporarily to test

Run apt without the proxy to verify connectivity to package repositories:

bash
sudo apt -o Acquire::http::Proxy=false update

If this succeeds, your issue is with the proxy configuration. If it still fails, the problem is network connectivity to repositories.

5Clear and reconfigure proxy settings

If proxy is no longer needed, remove it from configuration:

bash
# Remove proxy configuration files
sudo rm /etc/apt/apt.conf.d/proxy.conf

# Or comment out proxy lines in apt.conf
sudo nano /etc/apt/apt.conf

Unset environment variables:

bash
unset http_proxy https_proxy ftp_proxy
unset HTTP_PROXY HTTPS_PROXY FTP_PROXY

Then retry the apt command:

bash
sudo apt update
6Use IP address instead of hostname

Some networks have DNS issues that prevent hostname resolution for proxy servers. Try using the IP address directly:

Instead of:

bash
Acquire::http::Proxy "http://proxy.example.com:8080/";

Use:

bash
Acquire::http::Proxy "http://192.168.1.100:8080/";

Advanced notes

If your network uses a PAC (Proxy Auto-Config) file, you cannot directly use it with apt. Instead, retrieve the PAC file, decode it to find the actual proxy server address, and configure apt with that address. Some corporate networks use transparent proxies that don't require explicit configuration - in that case, remove all proxy settings from apt. For rootless systems or containers, the proxy configuration may need to be set differently - check the specific container runtime documentation.

Frequently asked questions

What does "E: Could not connect to proxy server" mean?
The apt package manager has been configured to use a proxy server for downloading packages, but it cannot establish a connection to that proxy. This typically indicates a network connectivity issue between your system and the proxy server, misconfiguration in apt settings, or the proxy server being offline.
How do I fix "E: Could not connect to proxy server"?
This error occurs when apt cannot establish a connection to a configured proxy server. Common causes include incorrect proxy configuration, unreachable proxy server, wrong credentials, or firewall blocking.
What causes "E: Could not connect to proxy server"?
Incorrect proxy server address or port in apt configuration Proxy server is offline or unreachable on the network Firewall rules blocking connection to the proxy server
Is the "E: Could not connect to proxy server" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading