Set Proxy Environment Variables for the Terminal

Route command-line tools like curl, wget, git, and pip through an HTTP or SOCKS proxy using http_proxy, https_proxy, and all_proxy.

LinuxcurlproxyenvironmentLow risk
Export http_proxy and https_proxy to your proxy address, e.g. export https_proxy=http://127.0.0.1:7890, then run your commands as usual.

01Command

Command
$ export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

02What it does

Most command-line programs read the http_proxy, https_proxy, and all_proxy environment variables, so exporting them once makes the whole shell session go through your proxy — useful when a corporate network requires it or when you run a local client like Clash or v2ray. Use http:// for an HTTP proxy port and socks5:// for a SOCKS proxy in all_proxy. The setting only lives in the current terminal; add the export line to ~/.bashrc or ~/.zshrc to make it permanent, and use unset to go back to a direct connection.

03Risk

RiskLow risk
!Warning: A proxy set this way is not encrypted or audited — make sure you trust the proxy host, and remember sudo commands may not inherit these variables unless you configure sudo's env_keep.

04Undo

Undo
$ unset http_proxy https_proxy all_proxy

05Sources

  • Proxy server — Environment variables
    Arch Wiki · community · 2026-09-17
    Evidence: Explains the http_proxy, https_proxy and all_proxy environment variables used by most command-line tools to route traffic through a proxy.
  • curl man page — proxy environment variables
    curl · vendor-doc · 2026-09-17
    Evidence: Documents that curl reads the http_proxy, HTTPS_PROXY and ALL_PROXY environment variables when no explicit --proxy option is given.

Last verified: 2026-09-18 · Category: Network