7

I'm working in a office behind a corporate firewall. My System is windows7, using componentes consola. Usually I need to set up proxy connections to get GIT working with github.

But when I try to clone a repository sored in a private Stash (Atlassian) I get this error:

Cloning into 'apptest'...
fatal: unable to access 'https://xxx@xxx.xx.xx.xx:xxxx/apptest/apptest.git
/': Received HTTP code 504 from proxy after CONNECT

I have unsetted git proxy but I'm still facing same problem. Please note that I'm using GITshell over Windows 7

Any help would be appreciated.

Regards

manuelbcd
  • 3,106
  • 1
  • 26
  • 39
  • 2
    Please [edit] your question to include what OS (including version) and what shell (bash, cygwin, Windows cmd.exe, PowerShell, etc.) you are running this on. – shoover Jan 12 '16 at 17:05

3 Answers3

33

Problem solved.

Windows: Before connecting Bitbucket (AKA stash) you need to clean all proxies from both Git and console environment:

SET HTTP_PROXY=
SET HTTPS_PROXY=
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone http://yourUser@stashAddress:stashPort/apptest.git

But if you need to connect to public repositories like github, then it's necessary to define proxies again:

SET HTTP_PROXY=proxyaddress:port
SET HTTPS_PROXY=proxyaddress:port
git config --global http.proxy http://proxyaddress:port
git config --global https.proxy http://proxyaddress:port

I think it may be useful for other developers working behind corporate firewalls.

Linux

unset HTTP_PROXY
unset HTTPS_PROXY
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone http://yourUser@stashAddress:stashPort/apptest.git

To define proxies again:

export HTTP_PROXY=proxyaddress:port
export HTTPS_PROXY=proxyaddress:port
git config --global http.proxy http://proxyaddress:port
git config --global https.proxy http://proxyaddress:port

Take care with uppercase of environment variables. Some OS versions may need lowercase or may have defined lowercase variables by default.

manuelbcd
  • 3,106
  • 1
  • 26
  • 39
  • I got the same issue after tried several tricks to fix `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` from here(https://stackoverflow.com/questions/45884752/npm-err-code-unable-to-get-issuer-cert-locally). Then this issue comes after I tried all of the suggestions in that post. Now it's fixed after I ran `git config --global --unset http.proxy` – Franva Aug 16 '21 at 01:35
  • That is great @franva – manuelbcd Aug 23 '21 at 08:52
  • This post has saved me multiple times. Has it not been set as the accepted answer? – bpilling Jan 18 '22 at 22:27
  • To be honest @bpilling I have never considered that possiblity... Do I have to do anything to help flagging it as accepted answer? – manuelbcd Jan 19 '22 at 10:59
  • I think you can just tick the check symbol next to? Not totally sure - I'm not super experienced on stackoverflow. – bpilling Jan 24 '22 at 01:52
  • Wow, you are right... I forgot I was the asker :D, thank you – manuelbcd Jan 24 '22 at 11:34
1

Problem Solved in SourceTree

Hoping this might be of any help to other developers who use (like I do) SourceTree on Windows. Many thanks to @manuelbcd for his initial answer.

I was experience a similar problem (HTTP status code was 502 with the same error message) when I was trying to fetch, pull or push from the BitBucket, and no extra configuration was done in my local git configuration, and I could not understand why I was getting this error.

SOLUTION In the list of the Environment Variable (Windows 7) HTTP_PROXY and HTTPS_PROXY were set. Since I did not need them I removed from there and relaunched SourceTree.

In order to find the Environment Variable (Windows 7) click on Start and type enviro. At the top of the menu comes out the line Edit environment variable..., click on it, remove/rename the variable and save.

Relaunch SourceTree at the end.

Davide Martorana
  • 691
  • 3
  • 8
  • 20
0

If you definitely need the proxy and can't remove it (eg: if you're on a corporate proxy) then just use the ssh to clone the repo.

Raj Shah
  • 766
  • 7
  • 15