git through a proxy: HTTP and SOCKS5
git speaks proxies differently over HTTPS and over SSH. This guide covers both: http.proxy for HTTPS remotes (including SOCKS5), and a ProxyCommand for SSH remotes — with per-host scoping so only the right traffic is routed.
HTTPS remotes vs SSH remotes
How you proxy git depends entirely on your remote's protocol. For HTTPS remotes (URLs like https://github.com/...), git uses libcurl, so it honours the http.proxy config and the standard http_proxy environment variables — and because it is libcurl, it accepts a SOCKS5 proxy via the socks5h:// scheme just like curl does. For SSH remotes ([email protected]:...), git is not involved in the networking at all; SSH is, so you configure a ProxyCommand in your SSH config to tunnel the connection.
With s4m you have both endpoints: SOCKS5 on port 1080 and HTTP on port 3128, authenticated with USER:PASS against proxy.s4m.online. For HTTPS remotes, socks5h:// keeps DNS remote; for SSH, a ProxyCommand using nc or ncat routes the SSH stream through SOCKS5. See the proxy page and what is SOCKS5; the same ProxyCommand idea appears in the SOCKS5 vs HTTP comparison.
git over HTTPS and SSH, proxied
http.proxy for HTTPS remotes (SOCKS5 or HTTP), plus a ProxyCommand for SSH. Per-URL scoping avoids proxying everything. Replace USER:PASS.
# --- HTTPS remotes: SOCKS5 with remote DNS --- git config --global http.proxy socks5h://USER:[email protected]:1080 # or the HTTP proxy: git config --global http.proxy http://USER:[email protected]:3128 # --- Scope the proxy to ONE host only (leave the rest direct) --- git config --global http.https://github.com/.proxy \ socks5h://USER:[email protected]:1080 # --- Remove the proxy later --- git config --global --unset http.proxy # --- SSH remotes: tunnel git@... through SOCKS5 via ~/.ssh/config --- cat >> ~/.ssh/config <<'CFG' Host github.com HostName github.com User git ProxyCommand nc -X 5 -x proxy.s4m.online:1080 %h %p CFG # -X 5 = SOCKS5; nc/ncat must be installed. # --- One-off, no persistent config --- git -c http.proxy=socks5h://USER:[email protected]:1080 clone https://example.com/repo.git
Proxy git the right way
Choose your remote type first, then apply the matching config.
Identify your remote protocol
Run git remote -v. An https:// URL uses http.proxy; a git@host: URL uses SSH, which needs a ProxyCommand instead.
For HTTPS, set http.proxy
Use git config --global http.proxy with socks5h://proxy.s4m.online:1080 for remote DNS, or the HTTP endpoint on 3128. Scope it per-URL if you only want one host proxied.
For SSH, add a ProxyCommand
In ~/.ssh/config, add ProxyCommand nc -X 5 -x proxy.s4m.online:1080 %h %p under the relevant Host block. Install nc/ncat if it is missing.
Verify with a clone
Clone a small repo and confirm it succeeds. If it hangs, re-check the endpoint and credentials, and make sure you scoped the right protocol.
Per-host scoping, auth and honesty
You rarely want to route all git traffic through a proxy. git supports per-URL proxy config — http.https://github.com/.proxy applies a proxy only to that host, leaving other remotes direct. That keeps internal mirrors fast while an external host goes through the proxy. Credentials live inline in the proxy URL; if your password has special characters, URL-encode them.
s4m proxies are authenticated datacenter SOCKS5 and HTTP endpoints, metered pay-as-you-go — a solid fit for CI runners cloning dependencies from behind a controlled egress, or for reaching a git host from a restricted network. They are datacenter, not residential, and a proxy changes only your network path, not your git credentials or SSH keys. When CI needs one allowlisted egress IP, add a dedicated personal IP. A 407 over HTTPS means bad proxy credentials — see the 407 guide. Validate endpoints with the tools and read the API docs.
Questions, answered
How do I make git use a SOCKS5 proxy?
For HTTPS remotes, set git config --global http.proxy socks5h://USER:[email protected]:1080 — git uses libcurl, so it accepts SOCKS5 just like curl. For SSH remotes, use a ProxyCommand in ~/.ssh/config instead.
Does http.proxy work for SSH (git@...) remotes?
No. http.proxy only affects HTTPS remotes. SSH remotes are proxied at the SSH layer with a ProxyCommand — for example nc -X 5 -x proxy.s4m.online:1080 %h %p for SOCKS5.
How do I proxy only one git host?
Use per-URL config: git config --global http.https://github.com/.proxy
How do I remove a git proxy?
Run git config --global --unset http.proxy (and any per-URL variant), or delete the ProxyCommand line from ~/.ssh/config for SSH remotes.
Clone from behind a proxy
Authenticated SOCKS5 (1080) and HTTP (3128) proxies on proxy.s4m.online, ready for http.proxy and SSH ProxyCommand. Metered pay-as-you-go, dedicated IP for CI allowlists.
People found this page by searching for
- git through a proxy
- git through a proxy for beginners
- how to check git through a proxy
- git through a proxy explained
- how to configure git through a proxy
- free proxy list without registration
- best vpn kill switch 2026
- how to check if a proxy is valid (with a ready script)
- how to set up ip address
- port forwarding through VPNs and proxies
- how websites detect proxies and VPNs
- what is proxy authentication
- proxy for scraping provider
- VPN kill switch
- fresh proxy authentication
Real search phrases this page answers — the linked ones open the page that covers them in depth.