Notes on networking and developer tooling
Proxy Setup
4 min read

Git Proxy Setup: Configure http.proxy and Fix Slow Clones

Git over HTTPS reads http.proxy (or the https_proxy variable) and accepts http://, socks5:// and socks5h:// URLs. Git over SSH ignores both and needs ProxyCommand. A slow clone is easiest to diagnose with GIT_CURL_VERBOSE.

Editorial team

Git over HTTPS uses the http.proxy setting (or the https_proxy environment variable) and accepts http://, socks5:// and socks5h:// proxy URLs. Git over SSH ignores both and needs a ProxyCommand in ~/.ssh/config. If a clone is slow, find out where the time goes before changing settings. This article describes behavior as of November 2026.

How do I make git use a proxy for HTTPS remotes?

Set http.proxy with git config. Despite the name, git hands HTTPS requests to libcurl, and the same setting covers both http:// and https:// remotes. You can also set the proxy for a single shell session with an environment variable instead of touching your config file.

git config --global http.proxy http://proxy.example.com:8080
git config --global --get http.proxy

# or, for the current shell only
export https_proxy=http://proxy.example.com:8080
git clone https://github.com/example/repo.git

If the proxy needs credentials, put them in the URL: http://user:password@proxy.example.com:8080. Percent-encode special characters in the password (for example @ becomes %40), and remember that ~/.gitconfig is a plain-text file. Prefer lowercase variable names such as https_proxy and no_proxy; they are read by every curl-based tool.

Git does not read the proxy panel of your browser or operating system. If a page opens in the browser but git clone hangs, that is the first thing to check.

Should I use socks5 or socks5h with git?

Use socks5h:// when you want the proxy to resolve the hostname for you. With socks5://, your machine resolves the name locally and sends only an IP address to the proxy, which fails when local DNS is wrong or blocked. HTTP proxies always receive the hostname.

git config --global http.proxy socks5h://user:password@proxy.example.com:1080

The scheme must match the protocol that the port actually speaks. Pointing an http:// URL at a SOCKS port, or the other way around, is the most common cause of "Failed to connect" and "Proxy CONNECT aborted" style errors.

How do I proxy only one host, or switch the proxy off?

Git lets you attach http.proxy to a URL prefix, so only matching remotes use it. An empty value disables the proxy for that prefix, which is useful for an internal server that should be reached directly.

git config --global http.https://github.com.proxy http://proxy.example.com:8080
git config --global http.https://git.internal.example.com.proxy ""

# remove the global setting
git config --global --unset http.proxy

# list everything proxy-related that git can see
git config --show-origin --get-regexp proxy

Environment variables work too: no_proxy=git.internal.example.com keeps one host off the proxy. Check git config --show-origin when behavior surprises you, because system, global and repository-level files all apply.

How do I send git over SSH through a proxy?

SSH remotes such as git@github.com:example/repo.git do not use http.proxy. Tell OpenSSH how to reach the server with ProxyCommand. The example below uses the OpenBSD flavor of netcat, where -X 5 selects SOCKS5 (use -X connect for an HTTP proxy) and -x gives the proxy address.

Host github.com
  ProxyCommand nc -X 5 -x proxy.example.com:1080 %h %p

Other netcat builds use different flags, and on Windows you would use a helper such as the connect tool shipped with Git for Windows; check its usage text. Passing a proxy password through nc is awkward, so a proxy that authorizes by source IP is easier here. If you only need to get around a blocked port 22, switching the remote to its HTTPS URL is often simpler than configuring SSH at all.

Why is my git clone slow, and how do I find out?

A slow clone has a handful of usual causes: the proxy is not actually used, DNS is slow, the repository history is large, or a protocol hiccup stalls the transfer. Work through them in order, starting with the cheapest check. Measure first; every change below is reversible.

  1. Confirm the path. Run GIT_CURL_VERBOSE=1 git clone https://github.com/example/repo.git and look at the connection lines. They should name your proxy host, not the remote server.
  2. Compare with curl. curl -x http://proxy.example.com:8080 -I https://github.com uses the same library. If curl is also slow, the problem is the network path, not git.
  3. Fetch less. git clone --depth 1 --single-branch URL downloads one commit. git clone --filter=blob:none URL skips file contents until you need them. git fetch --unshallow restores full history later.
  4. Try HTTP/1.1. git -c http.version=HTTP/1.1 clone URL works around stalls that occur in the middle of "Receiving objects".
  5. Fail fast. Set http.lowSpeedLimit and http.lowSpeedTime so git aborts a transfer that stays below a threshold instead of hanging forever.
SymptomLikely causeWhat to try
Hangs before any outputProxy unreachable, or slow DNSTest with curl; try socks5h://
Received HTTP code 407 from proxyMissing or wrong credentialsCheck URL encoding of the password
Failed to connect to proxyWrong host, port or schemeMatch http:// or socks5h:// to the port
Starts fast, stalls while receiving objectsLarge history or HTTP/2 stallShallow or partial clone; HTTP/1.1
Works in a browser onlyGit ignores OS proxy settingsSet http.proxy

Where AnboVPN fits

AnboVPN's HTTP/SOCKS5 proxy gives you an exclusive IP that speaks both HTTP (including HTTPS tunnels) and SOCKS5, with one set of username and password, so either URL form above works. You can also set a source-IP allowlist so your machine does not need a password in ~/.gitconfig. Usage counts against your data plan and the proxy stops when the plan runs out, so shallow and partial clones are worth using. See the HTTP/SOCKS5 proxy page.

References

git
proxy
SOCKS5
ProxyCommand
git clone

FAQ

Does git read the http_proxy and https_proxy environment variables?
Yes. Git uses libcurl for HTTP and HTTPS remotes, and libcurl reads https_proxy, http_proxy, all_proxy and no_proxy. Lowercase names are the safe choice because curl deliberately ignores an uppercase HTTP_PROXY for security reasons. A value in git config such as http.proxy takes precedence over the environment, so check both if behavior is unexpected.
Why does git over SSH ignore my http.proxy setting?
The http.proxy option only applies to HTTP and HTTPS transport. SSH remotes open their own TCP connection through the ssh program, so the proxy has to be configured there with ProxyCommand in ~/.ssh/config. Alternatively, change the remote URL to its https:// form with git remote set-url and let http.proxy handle it.
How can I see which proxy git is actually using?
Run git config --show-origin --get-regexp proxy to list every proxy setting and the file it comes from, and env | grep -i proxy for environment variables. Then run the failing command with GIT_CURL_VERBOSE=1 and read the connection lines: they show whether git connected to your proxy host or straight to the remote.
Is it safe to store proxy credentials in git config?
The value is saved as plain text in ~/.gitconfig, so anyone who can read that file can read the password. On shared machines prefer a proxy that authorizes by source IP, or export the proxy URL only in the current shell session. Never commit a repository-level config file that contains credentials.
Ad
  • Dynamic, residential and ISP residential IPs
  • Unlimited devices on one account
  • Smart routing and TUN mode
Free data on sign-up