How to fix E: Could not connect to proxy server in APT
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- Verify proxy configuration files
- Test proxy server connectivity
- Verify proxy credentials if required
- Bypass proxy temporarily to test
sudo cat /etc/apt/apt.confsudo cat /etc/apt/apt.conf.d/proxy.confcat ~/.bashrc | grep -i proxycat /etc/environment | grep -i proxyE: 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
- 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
- Incorrect username or password for proxy authentication
- Proxy server requires credentials but none are provided
- Network connectivity issues between client and proxy
- Special characters in proxy credentials not properly URL-encoded
How to fix "E: Could not connect to proxy server"
Check if apt is configured to use a proxy by examining these files:
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 proxyLook for lines like:
Acquire::http::Proxy "http://proxy:port";
Acquire::https::Proxy "https://proxy:port";
http_proxy=http://proxy:portVerify the proxy server is reachable using telnet or nc:
telnet proxy.example.com 8080Or using nc:
nc -zv proxy.example.com 8080A successful connection shows no error message. If connection is refused, the proxy is not accessible.
If your proxy requires authentication, ensure credentials are properly configured. Special characters in passwords must be URL-encoded:
# 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:
curl -x http://username:password@proxy:port http://example.comRun apt without the proxy to verify connectivity to package repositories:
sudo apt -o Acquire::http::Proxy=false updateIf this succeeds, your issue is with the proxy configuration. If it still fails, the problem is network connectivity to repositories.
If proxy is no longer needed, remove it from configuration:
# 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.confUnset environment variables:
unset http_proxy https_proxy ftp_proxy
unset HTTP_PROXY HTTPS_PROXY FTP_PROXYThen retry the apt command:
sudo apt updateSome networks have DNS issues that prevent hostname resolution for proxy servers. Try using the IP address directly:
Instead of:
Acquire::http::Proxy "http://proxy.example.com:8080/";Use:
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.