51

I've got MSysGit (Git on Windows) working just fine on my home machine, but at work, where we are behind a Microsoft ISA proxy, I get the following error when I do a Git clone:

H: cd \ git clone git://github.com/akitaonrails/vimfiles.git 

Output:

Initialized empty Git repository in H:/vimfiles/.git/ github.com[0: 65.74.177.129]: errno=Invalid argument fatal: unable to connect a socket (Invalid argument) 

I've tried setting the http_proxy environment variable to:

http://our-proxy-server:8088 

I've set the Git http.proxy configuration directive:

git config --global http.proxy http://our-proxy-server:8088 

Neither of the above makes a difference.

Doing a Git clone with http:// instead of git:// yields this:

H: cd \ git clone http://github.com/akitaonrails/vimfiles.git 

Output:

Initialized empty Git repository in H:/vimfiles/.git/ fatal: http://github.com/akitaonrails/vimfiles.git/info/refs download error - The requested URL returned error: 407 

407 is of course an authentication error.

Is there a way to get Git working from behind a proxy, specifically an ISA proxy? I don't know if it's going to be worth pursing this.

2
  • just added another potential fix Commented Jan 30, 2009 at 18:26
  • 1
    Thank you for the feedback. I take it you have now a Git1.6.4? Commented Sep 11, 2009 at 18:23

7 Answers 7

62

I had the exact same error; but the ~/.gitconfig global config file was the key.

If you have a proxy with authentication you need to put in it:

git config --global http.proxy http://login:password@our-proxy-server:8088 

And it just works (with 'git clone http:')

Example of a blog detailing the same setup: GIT clone over HTTP: who knew?


If it still fails in 407, it could be related to a problem with git-fetch losing authentication tokens on the second HTTP GET. A more recent version of libcurl might be needed.


Update January 2011: jbustamovej mentions in his answer (upvoted) his blog post "GitHub Behind Corporate Proxy", which adds this:

It’s important to note that if your login has a backslash, as in domain\login, you must escape the backslash, as in:

git config --global http.proxy http://domain\\\login:password@our-proxy-server:8088 

Also, the value of http.proxy can have "path" at the end for a socks proxy that listens to a unix-domain socket, but Git started to discard it when proxy was taught auth code path to use the credential helpers: that has been corrected with Git 2.47 (Q4 2024), batch 4.

See commit 0ca365c (02 Aug 2024) by Ryan Hendrickson (rhendric).
(Merged by Junio C Hamano -- gitster -- in commit 4bad011, 14 Aug 2024)

http: do not ignore proxy path

Co-authored-by: Jeff King
Signed-off-by: Jeff King
Signed-off-by: Ryan Hendrickson

The documentation for http.proxy describes that option, and the environment variables it overrides, as supporting "the syntax understood by curl".
curl allows SOCKS proxies to use a path to a Unix domain socket, like socks5h://localhost/path/to/socket.sock.
Git should therefore include, if present, the path part of the proxy URL in what it passes to libcurl.

git config now includes in its man page:

'[protocol://][user[:password]@]proxyhost[:port][/path]'. This can be overridden on a per-remote basis; see remote.<name>.proxy.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the tip, but I can't get this working. It still gives me a 407 (authentication) error even though I've set the proxy (complete with username and password) in both the environment and .gitconfig.
I just tried this again, since msysGit has been updated, and it worked. Hurrah! I guess libcurl must have been updated in the latest version.
Charles, what version do you have? With the new version, where do you put the proxy configuration? I'm getting the same problem and I tried a lot of manners.
19

Even after configuring the proxy, you might be unable to connect, since the proxy is disallowing Git protocol traffic. In this case, you might want to try using "http" instead of "git"

H: cd \ git clone http://github.com/akitaonrails/vimfiles.git 

Also, if you are using an automated proxy config file (.pac), just open it in a text editor. It is quite a easy to following scripting language, with a bunch of conditions to redirect to the most efficient proxy. Find the one that allows general purpose traffic (typically, the last configured proxy), and configure it as mentioned in the comment above.

3 Comments

Great! i had a similar problem with git, it was giving this error "Unable to connect to socket (no error)". I configured my --global http.proxy and i used http instead of git when cloning, and it worked.
This is exactly what my issue was. I didn't have to bother with the proxy stuff.
Obviously, this only works for git repos that are hosted via http. Ie. it'll work for github.com based repos. For others, you will need to get git working via your firewall/proxy
3

Do you have SOCKS proxy? If you have, you could try FreeCap to socksify your Git connection. I've been using Git this way for a while.

If not, still try FreeCap. IIRC it might be able to use HTTP proxies, but I haven't tried that.

I usually socksify cmd.exe using FreeCap, and from then on (almost) all cmdline programs that I start from that session are socksified too. That's why I recommended Free Cap, since SocksCap (another alternative) doesn't work that way.

As for using http.proxy, it for some reason never worked for me with the MinGW version and my company's HTTP proxies.

1 Comment

Thanks for this, FreeCap looks interesting. Are you able to elaborate on how you're using Git with it?
2

I've managed to get it working via a very convoluted route. Here's how:

  1. I have OpenSSH running on my home machine (a Vista box) running under Cygwin
  2. I am using Bitvise Tunnelier's Dynamic tunneling via integrated SOCKS/HTTP CONNECT proxy.
  3. I then use Freecap (thanks Marko) to "SOCKify" GIT-GUI. Unfortunately, you have to setup each EXE file individually and run them from within Freecap, so you can't universally SOCKify all of the Git command line tools. You can setup explicit command-line commands within Freecap, but you have to setup each individually, which kind of defeats the purpose. This is why I've just setup GIT-GUI in this crazy elaborate system

Amazingly, it seems to work, although I've not tested everything yet. It'll clone, certainly, which is a start.

Comments

1

Here is what worked for me:

git config --global http.proxy http://login:password@PROXY_SERVER:PORT git config --global http.sslVerify false 

1 Comment

An explanation would be in order. E.g., what is the idea/gist? From the Help Center: "...always explain why the solution you're presenting is appropriate and how it works". Please respond by editing (changing) your answer, not here in comments (*** *** *** *** *** without *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today).
1

Python 2.7 and ntlmaps worked for me after getting 407 errors and other junk from GitHub.

File .gitconfig:

[http] proxy = http://127.0.0.1:5865 

Comments

0

I had this problem on Windows 7:

git clone git://github.com/facebook/php-sdk.git 

Output:

Initialized empty Git repository in c:/Users/Jay/temp/php-sdk/.git/ github.com[0: 207.97.227.239]: errno=No error fatal: unable to connect a socket (No error) 

I finally realized it was AVG AntiVirus software running. I disabled the "resident shield" within AVG, and it worked like a charm.

git clone git://github.com/facebook/php-sdk.git 

Output:

Initialized empty Git repository in c:/Users/Jay/temp2/php-sdk/.git/ remote: Counting objects: 223, done. remote: Compressing objects: 100% (179/179), done. emote: Total 223 (delta 84), reused 0 (delta 0) Receiving objects: 100% (223/223), 37.32 KiB, done. Resolving deltas: 100% (84/84), done. 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.