Accessing Git from Behind the Proxy

So, you have installed Git client and trying to connect to Git server (on Visual Studio Team Services, Github, or whatever), but you're getting "fatal: unable to connect a socket (Invalid argument)" error. One of the reasons could is that you're behind the proxy. For example, you're at work and your employer requires all internet traffic to go through the proxy. ~/.gitconfig global config file is the key here. In this case, to get Git client to work with the proxy, you need to configure http.proxy key in git config using one of the following commands:

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

or

git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080

  • change proxyuser to your proxy user
  • change proxypwd to your proxy password
  • change proxy.server.com to the URL of your proxy server.
  • change 8080 to the proxy port configured on your proxy server

If you do not need to authenticate to proxy, then just specify proxy server name and port number and skip proxy user and password.

 

If you decide at any time to reset this proxy and work without (no proxy), use one of the the following commands:

git config --global --unset http.proxy

or

git config --global --unset https.proxy

 

Finally, to check the currently set proxy, use one of the following commands:

git config --global --get http.proxy

or

git config --global --get https.proxy

 

By the way, to retrieve the proxy settings you're using, you can use one of the following commands:

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"

or

netsh winhttp show proxy

That's all I got to say about Git and proxy server.