DEV Community

Stack All Flow
Stack All Flow

Posted on • Originally published at stackallflow.com on

Set HTTP(s) Proxy in Windows Command Line / Mac Terminal

MISCPROXY

Windows Command Line

In Windows Command Line environment (NOT powershell), you can use below commands to set http and https proxy.

set http_proxy=protocol://ip:port
set https_proxy=protocol://ip:port
Enter fullscreen mode Exit fullscreen mode

For example, if you have a local socks 5 proxy (such as ShadowSocks), commands will be as below.

set http_proxy=socks5://127.0.0.1:1086
set https_proxy=socks5://127.0.0.1:1086
Enter fullscreen mode Exit fullscreen mode

After setting, you can echo these variables to confirm.

echo %http_proxy%
echo %https_proxy%
Enter fullscreen mode Exit fullscreen mode

Set variable as empty to cancel the proxy

set http_proxy=
set https_proxy=
Enter fullscreen mode Exit fullscreen mode

MAC Terminal

export http_proxy=socks5://127.0.0.1:1086 # Set HTTP Proxy
export https_proxy=socks5://127.0.0.1:1086 # Set HTTPS Proxy
export all_proxy=socks5://127.0.0.1:1086 # Set HTTP & HTTPS Proxy
Enter fullscreen mode Exit fullscreen mode

To cancel HTTP Proxy in MAC Terminal, use unset command

unset http_proxy 
unset https_proxy
Enter fullscreen mode Exit fullscreen mode

These setting are only validated for current session, not impact system or other sessions.

PS: If your are running Shadowsocks, just disable system proxy instead of selecting mode as PAC or Global.

The post Set HTTP(s) Proxy in Windows Command Line / Mac Terminal appeared first on Stack All Flow.

Discussion (0)