Olga Chernyavskaya
Olga Chernyavskaya

Reputation: 1371

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.

Upvotes: 137

Views: 398810

Answers (23)

desy
desy

Reputation: 53

This error occurred for me because I had not updated my stored GitHub credentials in windows credentials, after I had generated a new login token on GitHub. Editing the windows credential password with the new token resolved the issue for me.

As mentioned by rekinyz, I also had to subsequently clear the old proxy settings which had been using a username & password:

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

Upvotes: 1

ndw
ndw

Reputation: 513

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.

enter image description here

Upvotes: 0

Luke
Luke

Reputation: 1

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.

Upvotes: 0

Prateek Mishra
Prateek Mishra

Reputation: 391

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.

Upvotes: 0

Codiee
Codiee

Reputation: 3245

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

Upvotes: 3

meappy
meappy

Reputation: 87

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

Upvotes: 3

marwaneL
marwaneL

Reputation: 31

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

Upvotes: 3

Ska
Ska

Reputation: 1

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

Upvotes: 0

meol
meol

Reputation: 1033

This config works in my setup:

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

Upvotes: 2

rekinyz
rekinyz

Reputation: 6622

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

Upvotes: 54

Vincent F
Vincent F

Reputation: 7371

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

Upvotes: 127

Marijus Ravickas
Marijus Ravickas

Reputation: 843

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

Upvotes: 74

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

Upvotes: 3

0190198
0190198

Reputation: 1717

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

Upvotes: 2

Shawn
Shawn

Reputation: 1891

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.

Upvotes: 0

user1989488
user1989488

Reputation: 123

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

Upvotes: 4

beaumondo
beaumondo

Reputation: 4930

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

Upvotes: 4

neo china
neo china

Reputation: 29

Your password seems to be incorrect. Recheck your credentials.

Upvotes: 1

Miroslav Mocek
Miroslav Mocek

Reputation: 877

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.

Upvotes: 44

Dave Lawrence
Dave Lawrence

Reputation: 1236

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

Upvotes: 0

Slak
Slak

Reputation: 588

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>

Upvotes: 2

rohitmohta
rohitmohta

Reputation: 1061

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.

Upvotes: 21

pinei
pinei

Reputation: 2323

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>

Upvotes: 8

Related Questions