Setting up your applications to connect through a proxy server enables you to access services that are behind a firewall or within a private network. It also allows you to conceal your IP address, and if the proxy server offers caching, it can accelerate access to specific resources.

Well-known programs that offer proxy capabilities include Squid, OpenSSH, and PuTTY. These programs can be configured to use proxies through HTTP, HTTPS, or SOCKS(4/5) protocols, which are typically employed to proxy HTTP and HTTPS traffic.

While most applications need specific configurations to utilize proxy servers, some Linux (including macOS and other Unix variants) terminal applications can use environment variable configuration to direct HTTP and HTTPS traffic via a proxy without configuring each application individually.

Steps to use HTTP and HTTPS proxy for Linux terminal applications:

  1. Set up a proxy server if you don't have one already.
  2. Open the terminal.
  3. Check if your terminal application is already using a proxy server for HTTP or HTTPS traffic (optional).
    $ curl
      "ip": "",
      "city": "Boston",
      "region": "Massachusetts",
      "country": "US",
      "loc": "42.3584,-71.0598",
      "org": "AS6984 Verizon Data Services LLC",
      "postal": "02108",
      "timezone": "America/New_York",
      "readme": ""

    For connection to the Internet, the output should display the gateway's IP address details.

    Example of supported tools are curl, wget, ftp, ssh, yum and apt.

  4. Verify if any HTTP or HTTPS proxy is currently set for the current terminal session.
    $ echo $http_proxy $https_proxy $HTTP_PROXY $HTTPS_PROXY

    No proxy if set if the command returns empty output

    http_proxy and https_proxy are the standard though HTTP_PROXY and HTTPS_PROXY are also commonly used. There's also ftp_proxy environment variable that you can use to route your FTP traffic through a proxy.

  5. Set the http_proxy or https_proxy environment variable for the current terminal session.
    $ export https_proxy=username:password@

    Format as the followings:


    Omit username and password if not required, like so:

    $ export https_proxy=

    Some supported proxy server protocols are http, https, socks4 and socks5

    Configure http_proxy environment variable to route HTTP traffic trough a proxy and configure https_proxy for HTTPS traffic.

  6. Configure the environment variable for every new terminal session for the current user (optional).
    $ echo 'export https_proxy=""' >> ~/.bashrc

    ~/.bashrc is a script executed on every new Bash terminal session. ~/.zshrc is the correshponding file for Zsh.

  7. Configure the environment variable for every new terminal session for all system users (optional).
    $ echo 'export https_proxy=""' | sudo tee -a /etc/profile 
  8. Confirm the environment variable has been set successfully.
    $ echo $https_proxy $http_proxy

    Launch new terminal if you were adding the proxy setting in any of the configuration files for the change to take effect.

  9. Test whether your application is now connecting through the configured proxy server.
    $ curl
      "ip": "",
      "hostname": "",  "city": "Boardman",
      "region": "Oregon",
      "country": "US",
      "loc": "45.8399,-119.7006",
      "org": "AS16509, Inc.",
      "postal": "97818",
      "timezone": "America/Los_Angeles",
      "readme": ""
  10. Disable the HTTP and HTTPS proxy for the current terminal session if it is no longer needed.
    $ unset http_proxy https_proxy
Discuss the article:

Comment anonymously. Login not required.