How to set a proxy for CMD/Powershell/Terminal/Git
in Other on Other Last modified at:
Way to set proxy for CMD & Powershell & Terminal & Gt Bash.
Set for CMD
Temporarily
Proxy will be invalid after closing the window. It’s a one-time setting.
HTTP/HTTPS
set http_proxy=http://IP:PORT
set https_proxy=http://IP:PORT
SOCKS
set http_proxy=socks5://IP:PORT
set https_proxy=socks5://IP:PORT
Set username and password
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=password
Permanently
# use IE proxy settings
netsh winhttp import proxy source=ie
# HTTP/HTTPS:
netsh winhttp set proxy proxy-server="http=IP:PORT" bypass-list="localhost"
# socks:
netsh winhttp set proxy proxy-server="socks=IP:PORT" bypass-list="localhost"
Show proxy settings
netsh winhttp show proxy
Remove proxy
netsh winhttp reset proxy
Set for Powershell
# HTTP
$env:HTTPS_PROXY="http://IP:PORT"
# HTTPS
$env:HTTP_PROXY="http://IP:PORT"
# SOCKS5
$env:all_proxy="socks5://IP:PORT"
You can save your password and username : "http://username:password@IP:PORT"
or "socks5://username:password@IP:PORT"
Set for Terminal
# HTTP/HTTTPS
export HTTP_PROXY=http://IP:PORT
# SOCKS5
export ALL_PROXY=socks5://IP:PORT
Set for Git
Temporarily
export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
Permanently
HTTP/HTTPS
git config --global http.proxy http://IP:PORT
git config --global https.proxy http://IP:PORT
Or you can edit .gitconfig
:
[http]
proxy = http://IP:PORT
[https]
proxy = http://IP:PORT
SOCKS5
git config --global http.proxy socks5://IP:PORT
git config --global https.proxy socks5://IP:PORT
Or you can edit .gitconfig
:
[http]
proxy = socks5://IP:PORT
[https]
proxy = socks5://IP:PORT
Show proxy settings
git config --get --global http.proxy
git config --get --global https.proxy
git config --get --global http.proxy socks5
git config --get --global https.proxy socks5
Remove proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset http.proxy socks5
git config --global --unset https.proxy socks5