Git proxy, npm proxy, Docker, WSL: commands to set, check and unset
Enter the proxy's address and pick your system: you get the commands that turn the proxy on in each program, check it, and turn it off again. Every command follows the program's own documentation, and the ones that can't use SOCKS5 say so.
Runs in your browser, nothing is sent
Check your connection
Links and subscriptions
Network and router
DNS and addresses
With a VPN in TUN mode, as Veli works, none of this is needed: the traffic of every program goes through the VPN by itself. WSL and Docker have networks of their own and may need settings.
Typemixed: HTTP and SOCKS5 on one port
Common ports
System
Programs
Environment variables
DocumentationFor this window
$env:HTTP_PROXY = "http://127.0.0.1:7890" $env:HTTPS_PROXY = "http://127.0.0.1:7890" $env:NO_PROXY = "localhost,127.0.0.1"
For good
[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://127.0.0.1:7890", "User")
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://127.0.0.1:7890", "User")
[Environment]::SetEnvironmentVariable("NO_PROXY", "localhost,127.0.0.1", "User")- Variables set for good appear in new windows.
For good
git config --global http.proxy http://127.0.0.1:7890
For one site only
git config --global http.https://github.com.proxy http://127.0.0.1:7890
For one command
git -c http.proxy=http://127.0.0.1:7890 ls-remote https://github.com/git/git.git HEAD
- http.proxy covers https:// addresses too.
- git@… addresses go over SSH, see “Git over SSH”.
For good
npm config set proxy http://127.0.0.1:7890 npm config set https-proxy http://127.0.0.1:7890 npm config set noproxy "localhost,127.0.0.1"
For one command
npm install --proxy http://127.0.0.1:7890 --https-proxy http://127.0.0.1:7890
For good
py -m pip config set global.proxy http://127.0.0.1:7890
For one command
py -m pip install --proxy http://127.0.0.1:7890 requests
curl
DocumentationFor one command
curl.exe -x http://127.0.0.1:7890 -I https://example.com
In the file$env:USERPROFILE\.curlrc
proxy = "http://127.0.0.1:7890" noproxy = "localhost,127.0.0.1"
- In Windows PowerShell 5.1 the word curl means Invoke-WebRequest, so type curl.exe.
Docker: pulling images
DocumentationSettings → Resources → ProxiesDocker Desktop
Web Server (HTTP): http://127.0.0.1:7890 Secure Web Server (HTTPS): http://127.0.0.1:7890 Bypass: localhost,127.0.0.1
- Docker Desktop: Settings, Resources, Proxies, “Manual proxy configuration”. It ignores proxies in daemon.json.
Everything is worked out in your browser: keys and addresses are not sent anywhere.
In Veli the same is set by sites and apps, without lists: what goes through the VPN and what goes direct. There is a package for OpenWrt routers. Free, no sign-up.
Download VeliReference
Where each program keeps its proxy
The same commands for an HTTP proxy at 127.0.0.1:7890, for Linux (winget: Windows). Change the address and the system above.
Git
Turn on
git config --global http.proxy http://127.0.0.1:7890
Turn off
git config --global --unset http.proxy
SOCKS5:yes
npm
Turn on
npm config set proxy http://127.0.0.1:7890 npm config set https-proxy http://127.0.0.1:7890
Turn off
npm config delete proxy npm config delete https-proxy npm config delete noproxy
SOCKS5:yes
pnpm
Turn on
pnpm config set --global https-proxy http://127.0.0.1:7890 pnpm config set --global http-proxy http://127.0.0.1:7890
Turn off
pnpm config delete --global https-proxy pnpm config delete --global http-proxy pnpm config delete --global noproxy
SOCKS5:yes
Yarn
Turn on
yarn config set -H httpProxy http://127.0.0.1:7890 yarn config set -H httpsProxy http://127.0.0.1:7890
Turn off
yarn config unset -H httpProxy yarn config unset -H httpsProxy
SOCKS5:no
pip
Turn on
python3 -m pip config set global.proxy http://127.0.0.1:7890
Turn off
python3 -m pip config unset global.proxy
SOCKS5:with PySocks
curl
Turn on
cat >> ~/.curlrc <<'EOF' # >>> proxy >>> proxy = "http://127.0.0.1:7890" # <<< proxy <<< EOF
Turn off
sed -i.bak '/# >>> proxy >>>/,/# <<< proxy <<</d' ~/.curlrc
SOCKS5:yes
wget
Turn on
cat >> ~/.wgetrc <<'EOF' # >>> proxy >>> use_proxy = on http_proxy = http://127.0.0.1:7890 https_proxy = http://127.0.0.1:7890 # <<< proxy <<< EOF
Turn off
sed -i.bak '/# >>> proxy >>>/,/# <<< proxy <<</d' ~/.wgetrc
SOCKS5:no
apt
Turn on
sudo tee /etc/apt/apt.conf.d/95proxy <<'EOF' Acquire::http::Proxy "http://127.0.0.1:7890/"; Acquire::https::Proxy "http://127.0.0.1:7890/"; EOF
Turn off
sudo rm /etc/apt/apt.conf.d/95proxy
SOCKS5:yes
dnf
Turn on
sudo sed -i.bak '/^proxy=/d' /etc/dnf/dnf.conf echo "proxy=http://127.0.0.1:7890" | sudo tee -a /etc/dnf/dnf.conf
Turn off
sudo sed -i.bak '/^proxy=/d' /etc/dnf/dnf.conf
SOCKS5:not documented
Docker: pulling images
Turn on
/etc/docker/daemon.json { "proxies": { "http-proxy": "http://127.0.0.1:7890", "https-proxy": "http://127.0.0.1:7890" } } sudo systemctl restart dockerTurn off
/etc/docker/daemon.json - "proxies": { … } sudo systemctl restart dockerSOCKS5:no
Cargo
Turn on
~/.cargo/config.toml [http] proxy = "http://127.0.0.1:7890"
Turn off
~/.cargo/config.toml [http] # proxy = "http://127.0.0.1:7890"
SOCKS5:yes
Go
Turn on
export http_proxy="http://127.0.0.1:7890" export HTTP_PROXY="http://127.0.0.1:7890" export https_proxy="http://127.0.0.1:7890" export HTTPS_PROXY="http://127.0.0.1:7890"
Turn off
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY all_proxy ALL_PROXY no_proxy NO_PROXY
SOCKS5:yes
Gradle
Turn on
cat >> ~/.gradle/gradle.properties <<'EOF' # >>> proxy >>> systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyPort=7890 systemProp.https.proxyHost=127.0.0.1 systemProp.https.proxyPort=7890 # <<< proxy <<< EOF
Turn off
sed -i.bak '/# >>> proxy >>>/,/# <<< proxy <<</d' ~/.gradle/gradle.properties
SOCKS5:yes
Maven
Turn on
~/.m2/settings.xml <settings> <proxies> <proxy> <id>local</id> <active>true</active> <protocol>http</protocol> <host>127.0.0.1</host> <port>7890</port> </proxy> </proxies> </settings>Turn off
~/.m2/settings.xml <settings> <proxies> <proxy> <id>local</id> <active>false</active> <protocol>http</protocol> <host>127.0.0.1</host> <port>7890</port> </proxy> </proxies> </settings>SOCKS5:no
VS Code
Turn on
~/.config/Code/User/settings.json "http.proxy": "http://127.0.0.1:7890"
Turn off
~/.config/Code/User/settings.json "http.proxy": ""
SOCKS5:yes
winget
Turn on
winget settings set DefaultProxy http://127.0.0.1:7890
Turn off
winget settings reset DefaultProxy winget settings --disable ProxyCommandLineOptions
SOCKS5:no
FAQ
How do I set a proxy for git, and how do I remove it?
git config --global http.proxy http://127.0.0.1:7890 turns it on for http and https addresses alike: git has no https.proxy of its own. git config --global --unset http.proxy turns it off. For one site only, use http.https://github.com.proxy. Addresses like git@github.com go over SSH and don't look at http.proxy.
Why doesn't npm, pip or apt see the proxy of my browser?
A browser follows the system's proxy settings. Terminal programs mostly don't: they read environment variables (HTTP_PROXY, HTTPS_PROXY) or a file of their own. And sudo drops the variables, so apt and dnf need the proxy in their config.
HTTP proxy or SOCKS5: which one to use in the terminal?
HTTP, if your proxy has it: every program here understands it. SOCKS5 works in git, curl, npm, cargo, Go and apt, pip needs the PySocks package for it, and wget, Yarn, Maven, winget and Docker have no SOCKS5 setting. Many local proxies answer both on one port, then pick “Mixed”.
What is the proxy address inside WSL2?
With networkingMode=mirrored (Windows 11 22H2 and newer) it is 127.0.0.1, the same as in Windows. In the default NAT mode 127.0.0.1 is WSL itself: the Windows address is the gateway from ip route show, it changes after a restart, and the proxy must accept connections from the network.
Why does the proxy work on the computer but not in a Docker container?
Inside a container 127.0.0.1 is the container itself. Use host.docker.internal (on Linux add --add-host=host.docker.internal:host-gateway), and the proxy must listen on more than 127.0.0.1. Pulling images is done by the daemon, which has its own setting.
How do I turn everything off?
Open the “Turn off” tab: it has the reverse command for every program, and “Download file” puts them into one script. Forgotten proxy settings are a common reason why git or npm can't connect after the proxy is closed.