http_proxy, https_proxy and no_proxy: Setup on Linux, Windows and Docker

Updated:

The HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables tell command-line tools and programming libraries which proxy to use and which addresses to reach directly. The standard syntax is http://user:pass@ip:port for both proxy variables, including HTTPS_PROXY, while NO_PROXY is a comma-separated list of domains or addresses. Set both the upper-case and lower-case forms, because tools differ in which one they read. This guide covers temporary and permanent setup on Linux, Windows and Docker, the cases where environment variables have no effect, and how to verify.

HTTP/HTTPS proxies ready for your servers

The three variables

The most common mistake is HTTPS_PROXY=https://.... The scheme in the value describes how to connect to the proxy itself, not to the website. A standard HTTP/HTTPS proxy accepts http:// connections, so both values start with http://. VinaProxy proxies are delivered as ip:port:user:pass; convert them to URLs with the proxy format converter if needed.

VariableExample valueEffect
HTTP_PROXY / http_proxyhttp://user:pass@ip:portProxy for http:// requests
HTTPS_PROXY / https_proxyhttp://user:pass@ip:portProxy for https:// requests; tools open a CONNECT tunnel through the HTTP proxy
NO_PROXY / no_proxylocalhost,127.0.0.1,.internal.localAddresses reached directly, bypassing the proxy

Upper case or lower case?

There is no single standard; each tool decides. For example, curl reads only lower-case http_proxy for HTTP requests, for security reasons, but accepts HTTPS_PROXY in either case. Python requests reads both. Other tools prefer one form and ignore the other. The safe approach is to set both forms to the same value.

If the password contains characters such as @, :, # or %, URL-encode it (@ becomes %40), or tools will split the string wrongly and you will get 407 Proxy Authentication Required.

Linux and macOS

  • Temporary, current terminal only: export http_proxy=http://user:pass@ip:port, then export https_proxy=$http_proxy, export HTTP_PROXY=$http_proxy, export HTTPS_PROXY=$http_proxy.
  • Bypass internal addresses: export no_proxy=localhost,127.0.0.1,.internal.local and export NO_PROXY=$no_proxy.
  • Permanent for your user: add those export lines to ~/.bashrc or ~/.zshrc and open a new terminal.
  • System-wide on Ubuntu: add http_proxy=http://user:pass@ip:port (without export) to /etc/environment, then log out and back in. Details are in the Ubuntu proxy setup guide.
  • sudo strips most environment variables by default. Use sudo -E command or configure env_keep if commands run with sudo also need the proxy.
  • apt does not reliably pick up environment variables under sudo; create /etc/apt/apt.conf.d/95proxy containing Acquire::http::Proxy "http://user:pass@ip:port/"; and a matching line for Acquire::https::Proxy.
  • To remove: unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY and delete the lines you added to config files.

Windows

  • CMD, current window only: set HTTP_PROXY=http://user:pass@ip:port and set HTTPS_PROXY=http://user:pass@ip:port.
  • PowerShell, current session: $env:HTTP_PROXY = 'http://user:pass@ip:port' and $env:HTTPS_PROXY = 'http://user:pass@ip:port'.
  • Permanent for your user: setx HTTP_PROXY http://user:pass@ip:port and setx HTTPS_PROXY http://user:pass@ip:port. They apply only to windows and apps opened afterwards.
  • Or use the UI: System Properties, Environment Variables, and add them under User variables.
  • Important: environment variables are separate from the Windows system proxy setting. Browsers and many GUI apps use the system setting, while curl, git, pip and Python read environment variables. The system setting is covered in the Windows proxy setup guide.

Docker: three different places

With Docker, the proxy may be needed in three places, and setting it in the wrong one is a common reason for "I set the proxy and it still fails".

  • The Docker daemon pulling images: the daemon does not see your terminal's variables. Create /etc/systemd/system/docker.service.d/http-proxy.conf with a [Service] section and Environment="HTTP_PROXY=http://user:pass@ip:port" "HTTPS_PROXY=http://user:pass@ip:port" "NO_PROXY=localhost,127.0.0.1", then run sudo systemctl daemon-reload and sudo systemctl restart docker.
  • Containers and builds: add a proxies block to ~/.docker/config.json with httpProxy, httpsProxy and noProxy; the Docker CLI then passes them into new containers and builds.
  • Per command: docker run -e HTTPS_PROXY=http://user:pass@ip:port image or docker build --build-arg HTTPS_PROXY=http://user:pass@ip:port ..
  • Inside a container, localhost is the container itself. If a proxy runs on the host, do not use 127.0.0.1 in the proxy value. The full walkthrough is in the Docker proxy setup guide.

Writing NO_PROXY correctly

  • Comma-separated, no spaces: localhost,127.0.0.1,.internal.local,api.company.com.
  • A leading dot as in .internal.local usually matches all subdomains; many tools treat internal.local the same way.
  • CIDR ranges such as 10.0.0.0/8 are supported by some tools and not others. To be safe, list addresses or use hostnames.
  • Always include localhost and 127.0.0.1 so local services do not loop through the proxy.
  • Add internal services, private package registries and database hosts to avoid confusing connection errors.

Verify, troubleshoot and stay safe

  • List current values: env | grep -i proxy on Linux, Get-ChildItem Env: | Where-Object Name -like '*proxy*' in PowerShell.
  • Check the exit IP with curl -s https://httpbin.org/ip and compare it with the proxy IP, or open what is my IP from that machine. Add -v to confirm curl really connects through the proxy. See the curl proxy guide.
  • Not every program reads environment variables. Some Node.js libraries and apps that manage their own networking need explicit proxy settings, as in the Node.js axios proxy setup.
  • Variables holding proxy passwords can leak through shell history, logs or process listings. Do not commit config files with passwords to Git; if one leaks, change the proxy password in the dashboard.
  • To remove proxy settings entirely, follow how to turn off a proxy.

Frequently asked questions

Should HTTPS_PROXY start with http:// or https://?

Almost always http://. The scheme describes the connection to the proxy, and a standard HTTP/HTTPS proxy accepts HTTP connections and tunnels HTTPS traffic.

Why does curl ignore my HTTP_PROXY?

curl reads only lower-case http_proxy for HTTP requests. Set the lower-case form too, or pass the proxy directly with -x.

Do environment variables make my browser use the proxy?

Usually not on Windows and macOS, where browsers use the system proxy setting. Environment variables mainly affect command-line tools and libraries.

Why does docker pull still fail after exporting the proxy?

The Docker daemon runs as a separate service and does not see your terminal's variables. Configure the proxy for the docker service through systemd and restart it.

Can I use these proxies through ALL_PROXY as SOCKS?

VinaProxy proxies are HTTP/HTTPS with username and password authentication. Use HTTP_PROXY and HTTPS_PROXY as shown above.

HTTP/HTTPS proxies ready for your servers

Private IPv4 in 7 countries and static ISP in Vietnam and the US. Username and password auth, ip:port:user:pass format, unlimited bandwidth.

See pricing

Related articles

Proxy setup
How to set up a proxy in Docker (Containers, Compose & Builds)
Route Docker containers and Docker Compose services through authenticated HTTP(S) proxies using HTTP_PROXY, HTTPS_PROXY and NO_PROXY. See the examples.
Proxy setup
How to Configure Proxy on Ubuntu & Debian Linux
Configure VinaProxy HTTP(S) proxies on Ubuntu Server and Desktop across /etc/environment, APT package manager, systemd daemons, and GNOME Network settings.
Proxy setup
How to use a proxy with cURL (command-line syntax & debugging)
How to use curl with authenticated HTTP(S) proxies (-x http://user:pass@ip:port and -U) on Linux, macOS and Windows, then check headers and latency.
Proxy setup
How to Configure Proxy on Windows 10 & Windows 11
Configure VinaProxy HTTP(S) proxies on Windows 10 and Windows 11 using WinINET System Settings, PowerShell Environment Variables, or netsh winhttp.
Products
Static residential ISP proxies
Static residential ISP proxies in the United States and Vietnam. IPs registered to consumer internet providers, dedicated to one customer, unlimited bandwidth.
Products
Private IPv4 datacenter proxies
Buy private IPv4 datacenter proxies in the US, Vietnam, Japan, South Korea, Singapore, the UK and Hong Kong. HTTP(S), unlimited bandwidth, auto activation.
ISP · vietnam
Vietnam Static ISP Proxies: Home-Network Vietnamese IPs for Your Most Valuable Accounts
Vietnam static ISP proxies on consumer internet provider IPs. A fixed Vietnamese IP for main Shopee shops, TikTok Shop, Facebook ad accounts and Zalo OA.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.