ChatGPT解决这个技术问题 Extra ChatGPT

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.

Duplicate of stackoverflow.com/questions/8561671? See my answer there about https proxy.
I was getting the same issue after I had updated my windows password on an AD environment. Turns out I just had to restart my proxy server (cntlm).

P
P.Brian.Mackey

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 did not need "git config --global http.sslVerify false", but this probably depends on the proxy configuration.
This answer is working, and should be marked as correct.
Needed to do it in git bash not DOS for me. I noticed DOS didn't anything! ie. check it by doing: git config --global -l
How is answer's git config --global http.proxy http://username:password@proxiURL:proxiPort different from the question's git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port> other than being less correct, because one needs to specify the proxy host, not the URL?
Works like charm
E
Eric Aya

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


This was what worked for me at last! after setting the proxy in the config file.
This was also the missing piece for me. Thank you. (Normally I don't bump with 'me too' comments, but this answer is pretty far down and needs more love).
This ended up being the only git config option I needed, as my https_proxy environment variable was set in /etc/environment.
M
Matt

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

This at least kept the error from appearing and generated a prompt for username / password. It seems that the git client is improperly setting the proxy by default sometimes. I've had the same error occur while using SourceTree by Atlassian.
This solved the issue for me on Ubuntu 14.04 after much head scratching!
This also solved it for me when using SourceTree, thanks.
I was getting this error when attempting to install homebrew...this solved my problem. Thanks.
Thank you, this is the only thing that worked for me when working from remote location through VPN tunnel.
M
Miroslav Mocek

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.


I tried all the options mentioned here and still it's not working for me. :(
Why the heck is everyone proposing to circumvent SSL verification??? THIS IS INSECURE and might compromise your system!
@flederwiesel Because corporate proxies are evil, and cause all sorts of stupidity - like having to store your domain credentials in cleartext in half a dozen places so you can actually access proxied resources. And forcing the use of insecure, company-issued root certificates - or bypassing/ignoring SSL verification entirely. It's quite sad.
r
rohitmohta

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.

Set 'all_proxy' environment variable for your user. Required by curl. export all_proxy=http://DOMAIN\proxyuser:proxypwd@proxy.server.com:8080 Set 'https_proxy' environment variable for your user. Required by curl. export https_proxy=http://DOMAIN\proxyuser:proxypwd@proxy.server.com:8080 I am not sure if this has any impact. But I did this and it worked: git config --global http.sslverify false 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.


You can use https_proxy=DOMAIN\"proxyuser:proxypwd"@proxy.server.com:8080 with double quotes and hav an @ in the password.
I know there is a trick using quotes " around login:password. But I actually tried and git ignored the quotes, so the @ in the password mess it up. If someone has a workaround, I think it's worth mentionning it.
I have tried all commands suggested above but after that i started getting Received HTTP code 407 from proxy after CONNECT.
You can URL encode any special characters. For instance @ becomes %40. meyerweb.com/eric/tools/dencoder
p
pinei

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>

b
beaumondo

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 wouldn't overwrite the default keystore "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt" but instead add your company's certificate to it (maybe in a separate file as described in the link).
u
user1989488

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


Are you sure about the command: "npm config...", because i guess it should be "git config..."
К
Кирилл Захаров

I had same problem in my organization.

After many attempts, I came to the following solution:

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. After that I add Git setting git config --global http.proxyauthmethod ntlm

Only after that I was able to clone my repository


m
marwaneL

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


m
meappy

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

What if there's another http.proxyAuthMethod value? How can I find out what's my system's?
S
Slak

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>

K
Kevin Katzke

Your password seems to be incorrect. Recheck your credentials.


0
0190198

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

m
meol

This config works in my setup:

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

C
Codiee

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


D
Dave Lawrence

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://username@bitbucket.org/sacgf/x.git/': Received HTTP code 407 from proxy after CONNECT

Note that we are using https:

$ git remote -v
origin  https://username@bitbucket.org/sacgf/x.git (fetch)
origin  https://username@bitbucket.org/sacgf/x.git (push)

Replace https url with http url:

$ git remote set-url origin http://username@bitbucket.org/sacgf/x.git
$ git pull
Username for 'https://bitbucket.org': username
Password for 'https://username@bitbucket.org': 
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

S
Shawn

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.


S
Ska

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


D
Daniël Verburgh

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


P
Prateek Mishra

I tried all of the solutions but none of them worked. Then I saw my .gitconfig file. It had multiple repeated entries and some of them were not correct(As I had tried multiple solutions). Finally I removed all the redundant and non needed settings and just kept the four settings mentioned by Sairam Kukadala, in his answer above, and Voila! it worked.


Sairam Kukadala's answer → stackoverflow.com/a/44831080/7389293
L
Luke

I saw this error when working on a corporate machine on Windows 10 that was not using a proxy.

From the Start menu, I had to open Settings > Network & Internet > Proxy and disable "Automatically detect settings". After doing this, GitHub was immediately able to clone the desired repo.

This may not help anyone else, but it worked for me when nothing else did.


n
ndw

Here's an alternate answer if you haven't tried any crazy proxy set up. Make sure that you are adding the repository through github.com or github enterprise instead of using a URL. If you are trying to use a github.com repository via the URL, you'll see the 407 error. Once I realized what I was doing my error went away.

https://i.stack.imgur.com/zaiTs.png