It's common to set up proxy servers in your operating system's UI. Windows and macOS have convenient proxy settings you can change without complicated steps.
Yet, some automation scripts, remote machines, testing environments, and other scenarios might require terminal proxy integration. If you're tech-savvy enough, using terminal commands could simply be more fun.
Why Use a Proxy in Terminal?
Setting up a proxy server in the terminal brings all the usual benefits. It routes your traffic and changes your IP address, ensuring privacy and helping bypass various restrictions. In certain scraping and automation scenarios, using a proxy in a terminal instead of setting it up elsewhere brings more specific benefits.
- Control of per-app or terminal session. Proxy servers can be applied to only one command or program.
- Admin privileges. Using environmental variables with no system-wide impact to set up proxies in the terminal may not require admin rights as opposed to OS settings, which are global.
- Easier to switch between proxies. Terminal settings can be changed with one line without affecting system preferences, which are useful when using multiple proxies.
These benefits are especially important when using proxy servers with various tools, like Docker containers or remote environments. Many popular command-line utilities, such as Wget or cURL, and version managers like Git, do not even have a graphical interface, or at least are not used with a GUI that frequently.
Terminal sessions are the only option to access them. So, if you need to bypass firewalls, change your location, or if general OS proxy settings are inapplicable, you'll need to set up proxies in the terminal.
Types of Proxies for Terminal Use
All types of proxy servers can be integrated into terminal sessions, so the choice depends more on your use case. Two things should be considered: proxy protocol support for your applications and proxy type to increase efficiency.
- HTTP/HTTPS protocols are supported by most command-line tools, such as cURL and Wget. HTTPS should be preferred in most cases as it secures traffic between you and the proxy server, although some older tools might not handle HTTPS well enough.
- SOCKS5 protocol is the most flexible, supporting TCP and UDP, so it's best for most command-line tools and automation tasks. It's generally the best choice unless your tools don't support it natively and require complicated setups.
When it comes to proxy server types by IP address source, datacenter proxies are most common due to being fast and cheap enough for general command-line tasks. However, these proxies can be easy to block for websites when you want to scrape data or automate web tasks.
Residential proxies are more reliable in such cases, as their IPs from residential internet service providers appear more legitimate, but may increase your costs. For accessing mobile-specific content, such as a social media site, mobile proxy servers with reliable mobile IPs should be chosen.

Step-by-Step Guide: Temporary Proxy Setup in Terminal
Windows
Windows systems allow setting temporary proxies using environment variables for the current terminal session with these steps.
- Press Windows button + R and type in cmd.
- Enter the following commands for HTTP and HTTPS proxies:
set HTTP_PROXY=http://<PROXY_HOST>:<PROXY_PORT>
set HTTPS_PROXY=http://<PROXY_HOST>:<PROXY_PORT>
For SOCKS5 proxies, use these commands:
set ALL_PROXY=socks5://<PROXY_HOST>:<PROXY_PORT>
3. In case your proxies require username and password authentication, you can integrate them into the set commands.
set HTTP_PROXY=http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT
set HTTPS_PROXY=http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT
set ALL_PROXY=socks5://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT
4. You can verify your proxy settings by using the command below, which will list all environmental variables for proxies.
set | find "PROXY"
These steps will configure your proxy server for your current terminal session. Once it's closed, the settings will need to be set again. You can clear these settings with empty commands as below.
set HTTP_PROXY=
set HTTPS_PROXY=
set ALL_PROXY=
Your proxy setup can also be tested by sending a simple wget command to a site that returns your proxy IP address on a successful connection.
wget https://ifconfig.me
MacOS
On Mac and some distributions of Linux, proxy servers can be set up with commands that define related environment variables.
- Click on the Launchpad icon and type in terminal in the search field. Then select Terminal.
- For HTTP and HTTPS proxies, enter the following commands:
export http_proxy="http://PROXY_HOST:PROXY_PORT"
export https_proxy="http://PROXY_HOST:PROXY_PORT"
If you're using SOCKS5 proxies, use the following:
export http_proxy="socks5://PROXY_HOST:PROXY_PORT"
export https_proxy="socks5://PROXY_HOST:PROXY_PORT"
3. In case your proxy requires username and password authentication, it can be included in the export command as such:
export http_proxy="http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT"
export https_proxy="http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT"
The export command for SOCKS5 proxies works similarly as well:
export http_proxy="socks5://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT"
export https_proxy="socks5://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT"
4. Your proxy settings can be verified using the command below, which will list all the environmental variables related to proxy settings.
env | grep -i proxy
These steps will integrate proxies with the terminal and verify their settings, but once the terminal session is closed, proxies will need to be configured anew. Yet, such a method is convenient when you need to use proxies with tools like cURL.
Your proxy setup can be tested by sending a simple cURL command to a site that will return your IP address, such as shown below. If your proxy IP address is shown, the configuration was successful.
curl https://ifconfig.me
Step-by-Step Guide: Permanent Proxy Setup in Terminal
Windows
Follow these steps to set up a system-wide proxy with Terminal for Windows devices:
- Press Windows button + R and type in cmd.
- Enter the following command and replace the placeholders <proxy> and <port>.
netsh winhttp set proxy <PROXY_HOST>:<PROXY_PORT>
3. If username and password authentication are needed with your proxy, you’ll need to set additional environmental variables, such as these:
set HTTP_PROXY=http://username:password@proxy_host:proxy_port
set HTTPS_PROXY=http://username:password@proxy_host:proxy_port
However, this will work only with command-line tools like cURL. To authenticate your proxy, use the Windows graphical interface. Alternatively, with IPRoyal proxies, you can use IP whitelisting authentication, which bypasses username and password.
Once you run this command, all applications and Windows services that rely on the WinHTTP component will use the proxy settings. To go back to default settings, use the command below:
netsh winhttp reset proxy
MacOS
Much like in macOS proxy settings, to configure system-level proxy in the terminal, you'll need to refer to a particular network interface device. The steps below assume you're using a Wi-Fi network.
- Click on the Launchpad icon and type in terminal in the search field. Then select Terminal.
- Enter the following commands:
networksetup -setwebproxy Wi-Fi localhost 8080
networksetup -setwebproxystate Wi-Fi on
If you are using SOCKS proxies, use these commands:
sudo networksetup -setsocksfirewallproxy Wi-Fi proxy.example.com 1080
sudo networksetup -setsocksfirewallproxystate Wi-Fi on
3. In case your proxy requires a username and password, macOS will ask for it when an app, such as the Safari browser, makes the first request.
These settings will affect all applications and services using the macOS network interface device. They will remain persistent until changed with a disabling command:
sudo networksetup -setwebproxystate Wi-Fi off

