git returns http error 407 from proxy after CONNECT

262,675

Solution 1

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

Solution 2

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

Solution 3

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

Solution 4

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.

Solution 5

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.

Share:
262,675

Related videos on Youtube

Olga Chernyavskaya
Author by

Olga Chernyavskaya

Updated on February 24, 2022

Comments

  • Olga Chernyavskaya
    Olga Chernyavskaya about 2 years

    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.

    • thinkOfaNumber
      thinkOfaNumber about 9 years
      Duplicate of stackoverflow.com/questions/8561671? See my answer there about https proxy.
    • Aaron C
      Aaron C almost 8 years
      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).
  • Vadorequest
    Vadorequest about 9 years
    You can use https_proxy=DOMAIN\"proxyuser:proxypwd"@proxy.server.com:808‌​0 with double quotes and hav an @ in the password.
  • Vadorequest
    Vadorequest about 9 years
    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.
  • user130934
    user130934 almost 9 years
    I have tried all commands suggested above but after that i started getting Received HTTP code 407 from proxy after CONNECT.
  • anre
    anre about 8 years
    I did not need "git config --global http.sslVerify false", but this probably depends on the proxy configuration.
  • Bryant
    Bryant about 8 years
    You can URL encode any special characters. For instance @ becomes %40. meyerweb.com/eric/tools/dencoder
  • Nadeem Iqbal
    Nadeem Iqbal over 7 years
    This answer is working, and should be marked as correct.
  • Kelly S. French
    Kelly S. French over 7 years
    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.
  • kolousek
    kolousek over 7 years
    This solved the issue for me on Ubuntu 14.04 after much head scratching!
  • jansohn
    jansohn over 7 years
    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).
  • Gaurav Lad
    Gaurav Lad over 7 years
    Are you sure about the command: "npm config...", because i guess it should be "git config..."
  • TomSW
    TomSW about 7 years
    This also solved it for me when using SourceTree, thanks.
  • jxgn
    jxgn about 7 years
    I tried all the options mentioned here and still it's not working for me. :(
  • joeCarpenter
    joeCarpenter almost 6 years
    I was getting this error when attempting to install homebrew...this solved my problem. Thanks.
  • theQuestionMan
    theQuestionMan over 5 years
    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
  • Dhanesh KM
    Dhanesh KM about 5 years
    This was what worked for me at last! after setting the proxy in the config file.
  • Matt
    Matt about 5 years
    Thank you, this is the only thing that worked for me when working from remote location through VPN tunnel.
  • Michel Jung
    Michel Jung about 5 years
    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?
  • Matt
    Matt almost 5 years
    @KellyS.French - Yes, because SourceTree is using GIT "under the hood": if Git console doesn't work, then you have issues with SourceTree too.
  • Danyl
    Danyl almost 5 years
    Thank you mate, you saved my day ! ;)
  • flederwiesel
    flederwiesel almost 5 years
    Why the heck is everyone proposing to circumvent SSL verification??? THIS IS INSECURE and might compromise your system!
  • Polycarp Kavoo
    Polycarp Kavoo over 4 years
    Works like charm
  • ggranum
    ggranum over 4 years
    @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.
  • ggranum
    ggranum over 4 years
    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).
  • Rakurai
    Rakurai almost 4 years
    This ended up being the only git config option I needed, as my https_proxy environment variable was set in /etc/environment.
  • carloswm85
    carloswm85 almost 3 years
    Sairam Kukadala's answer → stackoverflow.com/a/44831080/7389293
  • carloswm85
    carloswm85 almost 3 years
    What if there's another http.proxyAuthMethod value? How can I find out what's my system's?