git: Proxy CONNECT aborted
git clone through a proxy with a login stops before it reaches the server. One config line sends the login on the first try.
In short
Run git config --global http.proxyAuthMethod basic. git then sends the proxy login with the first CONNECT instead of waiting for a 407 that the proxy answers by closing the connection. If you get 407 from proxy after CONNECT instead, the login itself is wrong.
git doesn’t speak HTTP itself. For https:// remotes it hands the request to libcurl, and libcurl opens a tunnel through the proxy with CONNECT github.com:443. Everything inside that tunnel is encrypted; the proxy only ever sees the CONNECT line and its headers.
By default (anyauth) curl doesn’t know which login method the proxy wants, so it asks without one, reads the Proxy-Authenticate header of the 407 and tries again on the same connection. Many proxies close the connection right after the 407. curl then has no connection left to retry on, and git prints:
fatal: unable to access 'https://github.com/user/repo.git/': Proxy CONNECT abortedResidential proxy gateways, ours included, take a Basic login. Telling git that up front (http.proxyAuthMethod basic) puts Proxy-Authorization: Basic … on the very first CONNECT, and the round trip that breaks never happens.
The proxy closes after the 407
The case above: the login is right, but git never gets to send it. http.proxyAuthMethod basic fixes it for every repository; GIT_HTTP_PROXY_AUTHMETHOD=basic does the same for one command.
The login is wrong
Received HTTP code 407 from proxy after CONNECT means the proxy read the login and refused it. Copy user and password again from your provider. A password with @, :, # or / must be percent-encoded inside http.proxy: which characters and how. The same message from curl is covered in curl: (56) CONNECT tunnel failed, response 407.
The remote is SSH
git@github.com:user/repo.git goes over SSH, and SSH ignores http.proxy completely. Either switch the remote to HTTPS (git remote set-url origin https://github.com/user/repo.git) or give SSH a ProxyCommand. Most nc builds can’t send a proxy login, so with an authenticated proxy HTTPS is the simpler way.
An old proxy from the environment
curl also reads https_proxy, HTTPS_PROXY and all_proxy. A variable left over from another tool sends git to a proxy you forgot about. env | grep -i proxy shows them; git config --show-origin --get-regexp proxy shows which git config file sets one.
| Setting | What it does |
|---|---|
| http.proxy | Proxy for http:// and https:// remotes: http://USER:PASS@host:port |
| http.proxyAuthMethod | anyauth (default), basic, digest, negotiate, ntlm |
| http.https://github.com.proxy | Proxy for one host only |
| http.noProxy / NO_PROXY | Hosts that skip the proxy (curl reads the variable) |
| GIT_HTTP_PROXY_AUTHMETHOD | Same as http.proxyAuthMethod, for one shell or command |
| --unset http.proxy | Back to a direct connection |
Names as in the git-config documentation. SSH remotes use none of these.
A setup that works
Replace USER and PASS with your proxy login. Port 9000 gives a new IP per connection; that is fine for git.
git config --global http.proxy "http://USER-country-us:PASS@via.proxies.vision:9000"
git config --global http.proxyAuthMethod basic
git clone https://github.com/git/git.git --depth 1Only for one host, or one command
git config --global http.https://github.com.proxy "http://USER:PASS@via.proxies.vision:9000" limits the proxy to GitHub. For a single clone without touching any config: git -c http.proxy=http://USER:PASS@via.proxies.vision:9000 -c http.proxyAuthMethod=basic clone …
Targeting goes into the username as usual: USER-country-de for an exit in Germany. A socks5h:// URL on port 11000 works in http.proxy too, since curl handles SOCKS5 itself.
What does 'Proxy CONNECT aborted' mean in git?
How do I set a proxy with username and password for git?
Why does git still connect directly with http.proxy set?
How do I use a proxy for only one host in git?
How do I remove the git proxy setting?
Keep reading
Proxy Password With Special Characters (@ : # %)
A proxy password with @, :, # or % breaks the proxy URL. What curl, requests, httpx, Node and Go say, which encoding fixes it, and three traps we found.
6 min read · #authentication#errors
wget Proxy Authentication: https_proxy, 407 and an Ignored HTTPS_PROXY
wget through a proxy with a login: which variables it reads (not HTTPS_PROXY), --proxy-user, what 'Proxy tunneling failed' means, and BusyBox wget.
5 min read · #command-line#authentication
curl: (56) CONNECT tunnel failed, response 407 (Received HTTP code 407 from proxy)
curl (56) 'CONNECT tunnel failed, response 407', or 'Received HTTP code 407 from proxy after CONNECT' in older curl: the cause, the fix, every exit code.
6 min read · #errors#authentication
Residential proxies, pay per GB
HTTP and SOCKS5. Country, city and sticky sessions in the username. No subscription.