[git] git returns http error 407 from proxy after CONNECT

I have a problem while connecting to github from my PC, using git. System Win 7.

I have connection through proxy, so i specified it in git config files (both in general git folder, and in git repo folder). To do this i entered next line to my git bush:

$ git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>

The way it works on other programms (ex: maven) it looks like that:

<username> - my login to our corp system
<userpsw> -my password to corporat system
<proxy> - 10.65.64.77
<port> - 3128

But when i try to push or to clone my repo, i receive

fatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT

I try already to enter not just my username but domain\username, changed my password in case there are problems with code language tables. And i even entered wrong password. Error stayed the same.

When i entered in '10.65.64.177.com' and tried to push repo, i received:

fatal: unable to access '<repo github link>': Failed connect to github.com:3128; No error

Just don't know what to try.

This question is related to git github proxy

The answer is


FYI for everyone's information

This would have been an appropriate solution to resolve the following error

Received HTTP code 407 from proxy after CONNECT

So the following commands should be necessary

git config --global http.proxyAuthMethod 'basic'
git config --global https.proxy http://user:pass@proxyserver:port

Which would generate the following config

$ cat ~/.gitconfig
[http]
        proxy = http://user:pass@proxyserver:port
        proxyAuthMethod = basic

I had same problem in my organization.

After many attempts, I came to the following solution:

  1. I applied to the system administrator to change the proxy authentication type from Kerberos to NTLM. I'm not sure if it was mandatory (I'm an ignoramus in this matter), but my application was approved.

  2. After that I add Git setting

    git config --global http.proxyauthmethod ntlm

Only after that I was able to clone my repository


I had the same problem too, and tried to solve it by setting explicitly the http.proxyAuthMethod to basic.

After running a pcap trace between my server and the proxy, i noticed that the " HTTP CONNECT" request sent to the proxy during a git clone still not have a "Proxy-Authorization" header set to basic. This was due to my git version "1.8.3.1" that do not support http.proxyAuthMethod.

After installing a newest git version (2.16.6), using rpm packages foud here "https://repo.ius.io/7/x86_64/packages/g/", setting http.proxyAuthMethod to basic had finally an effect on git behavior and then my git clone was successful.

I hope this helps


I was facing the same issue, so firstly i checked my npm file what i have set, i checked it with this command:-

npm config get proxy

and i find out i have set wrong proxy and i set my desire proxy as follow:

npm config set proxy http://xxx.xxx.xxx.4:8080   
npm config set https-proxy http://xxx.xxx.xxx.4:8080

After that it works to me


I encountered the same issue when using Git Bash. When I did the same thing in Command Prompt it worked perfectly.


I think you should focus your efforts after you get to this point:

fatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT

This means that you have not properly authenticated with the proxy. Can you double check the password you provide in this step is correct?

git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>

Removing "@" from password worked for me and in anyways never keep @ in your password it will give you issue with maven and further installation


This issue occured a few days ago with my Bitbucket repositories. I was able to fix it by setting the remote url to http rather than https.

I also tried setting https proxies in the command line and git config but this didn't work.

$ git pull
fatal: unable to access 'https://[email protected]/sacgf/x.git/': Received HTTP code 407 from proxy after CONNECT

Note that we are using https:

$ git remote -v
origin  https://[email protected]/sacgf/x.git (fetch)
origin  https://[email protected]/sacgf/x.git (push)

Replace https url with http url:

$ git remote set-url origin http://[email protected]/sacgf/x.git
$ git pull
Username for 'https://bitbucket.org': username
Password for 'https://[email protected]': 
remote: Counting objects: 43, done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 43 (delta 31), reused 0 (delta 0)
Unpacking objects: 100% (43/43), done.
From http://bitbucket.org/sacgf/x
   a41eb87..ead1a92  master     -> origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to ead1a920caf60dd11e4d1a021157d3b9854a9374.
d

Your password seems to be incorrect. Recheck your credentials.


Had the 407 error from Android Studio. Tried adding the proxy, but nothing happened. Found out that it was related to company certificate, so I exported the one from my browser and added it to Git.

Export From Web Browser

Internet Options > Content > Certificates > Export (Follow wizard, I chose format "Base 64 encoded X.509(.CER))

In Git Bash

git config --global http.sslCAInfo c:\Utilities\Certificates\my_certificate

The following page was useful https://blogs.msdn.microsoft.com/phkelley/2014/01/20/adding-a-corporate-or-self-signed-certificate-authority-to-git-exes-store/

To add the proxy, like the other threads I used

git config --global http.proxy proxy.company.net:8080
git config --global https.proxy proxy.company.net:8080

I had the similar issue and I resolved with below steps:

** Add proxy details in git**

git config --global http.sslVerify false
git config --global https.sslVerify false
git config --global http.proxy http://user:pass@yourproxy:port
git config --global https.proxy http://user:pass@yourproxy:port

I had to setup all 4 things in .gitconfig with:

git config --global http.sslVerify false
git config --global https.sslVerify false
git config --global http.proxy http://user:pass@yourproxy:port
git config --global https.proxy http://user:pass@yourproxy:port

Only then the cloning was successful.


What worked for me is something similar to what rohitmohta is proposing ; in regular DOS command prompt (not on git bash) :

first

git config --global http.proxy http://username:password@proxiURL:proxiPort

and in some cases also

git config --global https.proxy http://username:password@proxiURL:proxiPort

then

git config --global http.sslVerify false

(I confirm it's necessary : if set to true getting "SSL certificate problem: unable to get local issuer certificate" error)

in my case, no need of defining all_proxy variable

and finally

git clone https://github.com/someUser/someRepo.git

I experienced this error due to my corporate network using one proxy while on premise, and a second (completely different) proxy when VPN'd from the outside. I was originally configured for the on-premise proxy, received the error, and then had to update my config to use the alternate, off-prem, proxy when working elsewhere.


Maybe you are already using the system proxy setting - in this case unset all git proxies will work:

git config --global --unset http.proxy
git config --global --unset https.proxy

I had the same problem in a Windows environment.

I just resolved with NTLM-APS (a Windows NT authentication proxy server)

Configure your NTML proxy and set Git to it:

git config --global http.proxy http://<username>:<userpsw>@localhost:<port>

This config works in my setup:

[http]
    proxy = <your proxy>
[https] proxy = <your proxy>
[http]
    sslVerify = false
[https]
    sslVerify = false   
[credential]
    helper = wincred 

Have the same problem while using sourcetree Reason was Maybe switching the System Proxy from on to off while sourcetree was open. For some reason this was written into the config file of a project. This can be easily deleted over sourcetree by "Settings" -> "Edit configuration file". Just delete it out there under http


I had faced similar issue, behind corporate firewall. Did the following, and able to clone repository using git shell from my system running Windows 7 SP1.

  1. Set 'all_proxy' environment variable for your user. Required by curl.

    export all_proxy=http://DOMAIN\proxyuser:[email protected]:8080
    
  2. Set 'https_proxy' environment variable for your user. Required by curl.

    export https_proxy=http://DOMAIN\proxyuser:[email protected]:8080
    
  3. I am not sure if this has any impact. But I did this and it worked:

    git config --global http.sslverify false
    
  4. Use https:// for cloning

    git clone https://github.com/project/project.git
    

Note-1: Do not use http://. Using that can give the below error. It can be resolved by using https://.

 error: RPC failed; result=56, HTTP code = 301

Note-2: Avoid having @ in your password. Can use $ though.


The following command is needed to force git to send the credentials and authentication method to the proxy:

git config --global http.proxyAuthMethod 'basic'

Source: https://git-scm.com/docs/git-config#git-config-httpproxyAuthMethod


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch

Examples related to proxy

Axios having CORS issue Running conda with proxy WebSockets and Apache proxy : how to configure mod_proxy_wstunnel? "Proxy server connection failed" in google chrome Set proxy through windows command line including login parameters Could not resolve all dependencies for configuration ':classpath' Problems using Maven and SSL behind proxy Using npm behind corporate proxy .pac git returns http error 407 from proxy after CONNECT Forwarding port 80 to 8080 using NGINX