Proxy environment variables let a Zsh terminal hand one outbound proxy policy to commands started from that shell. They are useful when direct Internet access is blocked or when terminal tools must leave through an office gateway, egress proxy, or temporary test relay.
Zsh only passes proxy values to child processes after they are exported. Lowercase http_proxy, https_proxy, and no_proxy work with common command-line clients such as curl and wget, while uppercase variants are best kept for applications that explicitly require them.
A current-shell export affects only the open terminal and is easy to remove with unset. Saving the same exports in ~/.zshrc makes new interactive Zsh terminals load the proxy automatically, so avoid putting long-lived proxy passwords in that file unless the account's credential policy allows it.
Related: How to configure Zsh startup files
Related: Set proxy environment variables in Bash
Related: Use proxy environment variables with cURL
Use the form http://host:port for a normal HTTP proxy. If credentials are required, prefer a task-local secret source over saving http://user:password@proxy.example.com:8080 in shell history or a shared startup file.
$ export http_proxy="http://proxy.example.com:8080"
Use lowercase http_proxy for HTTP proxy settings. Some clients ignore uppercase HTTP_PROXY for security reasons.
$ export https_proxy="http://proxy.example.com:8080"
The proxy URL often still starts with http:// because the client connects to the proxy over HTTP and opens a CONNECT tunnel for HTTPS destinations.
$ export no_proxy="localhost,127.0.0.1,.example.internal"
Separate entries with commas. A leading dot matches hosts under that domain for tools that implement domain-suffix matching.
$ printenv http_proxy https_proxy no_proxy http://proxy.example.com:8080 http://proxy.example.com:8080 localhost,127.0.0.1,.example.internal
$ zsh -fc 'printenv http_proxy https_proxy no_proxy' http://proxy.example.com:8080 http://proxy.example.com:8080 localhost,127.0.0.1,.example.internal
$ nano ~/.zshrc
Use $ZDOTDIR/.zshrc instead when the account stores Zsh startup files outside the home directory. Related: How to configure Zsh startup files
export http_proxy="http://proxy.example.com:8080" export https_proxy="http://proxy.example.com:8080" export no_proxy="localhost,127.0.0.1,.example.internal"
If the file already sets proxy variables, replace the old lines instead of leaving conflicting values later in the same startup file.
$ zsh -n ~/.zshrc
No output from zsh -n means Zsh parsed the file without finding a syntax error.
$ source ~/.zshrc
$ zsh -ic 'printenv http_proxy https_proxy no_proxy' http://proxy.example.com:8080 http://proxy.example.com:8080 localhost,127.0.0.1,.example.internal
$ curl --verbose http://example.com
Use client-specific proxy guides when the route itself needs proof. Related: How to use proxy environment variables with cURL
Related: How to use an HTTP proxy with wget
Tool: Proxy Server Checker
$ unset http_proxy https_proxy no_proxy HTTP_PROXY HTTPS_PROXY NO_PROXY
Remove the same lines from ~/.zshrc when future Zsh terminals should stop loading the proxy policy.