224

I installed Git to get the latest version of Angular. When I tried to run

git clone https://github.com/angular/angular-phonecat.git

I got:

failed to connect to github 443 error

I even tried

git clone git://github.com/angular/angular-phonecat.git

That gave me

failed to connect no error message

I am behind my company firewall. I can not see my proxy details when I go to Control PanelInternet OptionsConnectionsLAN setting. The IT guys are not sharing proxy information with me. What can do?


I finally managed to do it. I will update the procedure that I had taken in order to. I just wanted to compile all the steps that I did to get it to work.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anand
  • 14,545
  • 8
  • 32
  • 44
  • See this question on how to setup a proxy with git on Windows http://stackoverflow.com/q/16153450/579234 – Sogger Mar 03 '16 at 18:14
  • I realised that this can happen too if you just spam github with push requests from the terminal. And yes I realised that while inconsiously spamming. Edit: It has nothing to do with the proxy settings, but you can still get a 443 error. – AirOne Jun 09 '20 at 22:35
  • If u have socks5 proxy, simply use `git config --global http.proxy 127.0.0.1:1080` where 127.0.0.1 is the proxy URL, 1080 is the port. – YinchaoOnline Jun 16 '21 at 00:42
  • On Windows, presumably. But what command line environment? [Git Bash](https://superuser.com/questions/1053633/what-is-git-bash-for-windows-anyway)? Cmd? [PowerShell](https://en.wikipedia.org/wiki/PowerShell)? [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)? [Cygwin](https://en.wikipedia.org/wiki/Cygwin)? – Peter Mortensen Feb 24 '23 at 04:42
  • What are the actual literal error messages? – Peter Mortensen Feb 24 '23 at 05:09
  • Something like "`Failed to connect to github.com port 443: `"? – Peter Mortensen Feb 24 '23 at 05:44
  • Related: *[Getting Git to work with a proxy server - fails with "Request timed out"](https://stackoverflow.com/questions/783811/)* – Peter Mortensen Feb 24 '23 at 05:52

27 Answers27

421

Well, I did the following steps

  1. Google the error

  2. Got to SO links (here, here) which suggested the same thing that I have to update the Git configuration for proxy setting

  3. Damn, I can not see proxy information from Control Panel. The IT guys must have hidden it. I can not even change the setting to not to use a proxy.

  4. I found this wonderful tutorial of finding which proxy your are connected to

  5. Updated the http.proxy key in the Git configuration by the following command

    git config --global http.proxy http[s]://userName:password@proxyaddress:port
    
  6. Error - "could not resolve proxy some@proxyaddress:port". It turned out my password had a @ symbol in it.

  7. Encode @ in your password to %40, because Git splits the proxy setting by @

  8. If your userName is an email address, which has @, also encode it to %40. (see this answer)

     git config --global http.proxy http[s]://userName(encoded):password(encoded)@proxyaddress:port
    

Baam! It worked!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anand
  • 14,545
  • 8
  • 32
  • 44
  • 2
    How is this encoding done. Could you translate `http://johndoe:f@tm@n@example.com:80` into the encoded version, please? The last `@` need not be encoded – Igbanam Mar 19 '14 at 14:06
  • its very simple %40 is url encoded value of @, so replace all your @ in your password with %40. I guess "f@tm@n" is your password in the string that you wrote above. So it would become f%40tm%40n – Anand Mar 19 '14 at 14:23
  • does this encoding apply to domains too? Where the username is `mydom\me` making the string `http://mydom\me:f%40tm%40n@example.com:80` – Igbanam Apr 19 '14 at 22:37
  • 1
    Sidenote: Splitting the credentials from the url using `@` is not unique to github. This is actually [part of the url standard](http://www.w3.org/TR/url/#find-the-user-info,-host,-and-port). – Dan Esparza May 06 '14 at 14:05
  • @Anand: What is the user name and password here?. Is it the credential required for Proxy server or is it the credential required for GitHub? – KurioZ7 Sep 03 '14 at 04:48
  • that user name and password is for the proxy. Generally its your username and password which you use to login in to your office account – Anand Sep 03 '14 at 08:07
  • 5
    Unless your proxy requires a username and password, you don't need the "userName:password@" portion. – Keith Morgan Feb 11 '15 at 09:28
  • The tutorial you linked to appears to be windows only - is there a linux alternative? – Benubird Mar 27 '15 at 08:34
  • 3
    @Anand But I am not even on a proxy server, then what should I do to fix this error? What do I put in the proxy server? I am not using any proxy – Faizan Mar 29 '15 at 18:08
  • 1
    @Anand. Thanks for your explanation. i had an @ symbol in my password and your details explanation helped me. – Raghu Aug 20 '15 at 06:55
  • If you setup a local CNTLM proxy you can store your password encrypted too. See http://stackoverflow.com/a/18618941/579234 – Sogger Mar 03 '16 at 18:16
  • 1
    Sometimes the proxy does not need a password (you are inside of your firm network that has internet acess via a proxy-server), then you just put `git config --global http.proxy ` (you found the latter in the tutorial). – Ufos Oct 14 '16 at 15:49
  • + to easily find your proxy: go to http://wpad/wpad.dat and then in downloaded file look at proxyServer – Vahagn Nahapetyan Feb 07 '20 at 17:57
63

If your Git installing was already set to something and you only copied that folder to some other location, simply run:

git config --global http.proxy ""

And Git will set itself straight. After what, you can pull again :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
EvgenyKolyakov
  • 3,310
  • 2
  • 21
  • 31
  • 1
    helpful github desktop link https://help.github.com/desktop-classic/faq/articles/can-i-log-in-behind-a-proxy-server/ – user3366016 Jun 11 '18 at 15:08
36

If your country or working environment blocks sites like Github.

Then you can build a proxy, e.g. use xxnet, which is free & based on Google's GAE, and available for Windows / Linux / Mac.

Then set proxy address for git, e.g:

git config --global http.proxy 127.0.0.1:8087
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Eric
  • 22,183
  • 20
  • 145
  • 196
25

Mine was fixed by just using this command:

git config --global http.proxy XXX.XXX.XXX.XXX:ZZ

where XXX.XXX.XXX.XXX is the proxy server address and ZZ is the port number of the proxy server.

There wasn't any need to specify any username or password in my case.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Doe
  • 2,752
  • 5
  • 40
  • 58
18

If you are not using a proxy and are still facing this issue, you should use the below command line:

git config --global --unset http.proxy

Simply hit this command, and this will fix the issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Suraj Singh
  • 351
  • 3
  • 10
17

I got so:

git config --global http.proxy http://{domain}\\\{username}:{password}@{proxy ip}:{proxy port}

git config --global http.sslverify false
rmonte.com
  • 179
  • 1
  • 4
11

The same problem happened to me in Windows using Git for Windows.

I set a proxy setting as usual:

git config --global http.proxy http://username:pass@proxy.com:port

In my situation, the username is email, so it has a @ sign. After encoding the @ sign with %40 in the username, the problem is resolved.

So, encode the special characters not only in the password, but also in the username. (Refer to the comments of this answer.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
aruku7230
  • 843
  • 8
  • 20
  • but after adding gobal proxy , connection is getting refused from my work repo , it is not getting connected 443 error – Bhupendra Oct 09 '19 at 06:17
11

I have wide experience working with corporate proxies.

If you have configured the proxy and it's impossible to work with Git (always getting a 443 error), try to check if you have a remote.origin.proxy bypassing your configuration.

git config --list --show-origin

If you check that "remote.origin.proxy" is configured as an empty value, try to unset it or almost set it with your corporate proxy:

git config --add remote.origin.proxy "http://[yourproxy]:[yourport]"

And since several enterprise sites have untrusted certificates, I recommend you to avoid certificate checking if you are using SSL:

git config http.sslverify false
git config --global http.sslverify false
manuelbcd
  • 3,106
  • 1
  • 26
  • 39
11

Option 1 : Windows specific

Restart your machine

Option 2 : Unset your proxy

git config --global --unset https.proxy
13garth
  • 655
  • 1
  • 8
  • 22
7

ipconfig /renew - solved this issue for me.

digitalextremist
  • 5,952
  • 3
  • 43
  • 62
htpt
  • 79
  • 1
  • 1
6

I was getting the same error in Sourcetree.

Go to menu ToolsOptionsNetwork and check Add proxy server configuration to Git/Mercurial if you had already set the proxy settings.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
r_allela
  • 792
  • 11
  • 23
5

On Windows 7, setting the proxy to the global configuration will resolve this issue

git config --global http.proxy http://user:password@proxy_addr:port

But the problem here is your password will not be encrypted... Hopefully that should not be much problem as most of time you will be the sole owner of your PC.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jags
  • 111
  • 2
  • 7
  • 1
    To encrypt password, use CNTLM, see here: http://stackoverflow.com/a/18618941/579234 – Sogger Mar 03 '16 at 18:15
  • 2
    if you set the Proxy to http://user@proxy_addr:port, simply omitting the Password, git will work, giving you a Login prompt for your Proxy server when you connect. That works quite nicely. – MonsterMushroom Apr 03 '17 at 07:40
3

My problem was solved using this command

git config --global http.proxy http://login:password@proxyServer:proxyPort
ricardogobbo
  • 1,690
  • 3
  • 19
  • 41
2

If using an SSH configuration file, my issue was that the ~/.ssh/config file was not specified correctly. From Enabling SSH connections over HTTPS:

Host github.com
  Hostname ssh.github.com
  Port 443
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Clucking Turtle
  • 922
  • 1
  • 11
  • 24
2

I'm behind a proxy in Windows 10 (and in Windows 11), git 2.32.0.window.1. This is what worked for me.

Checking What You Have

Check your global configurations using:

git config --global --list

You should see the settings for user.name, user.mail, etc. Having the following lines in place fixed the problem for me:

http.proxyauthmethod=basic
http.proxy=http://username:password@proxyaddress:port
https.proxy=https://username:password@proxyaddress:port

Notice these are settings for both HTTP and HTTPS protocols. If you don't see both, you'll have to set them.

Setting The Proxy

Use this line of code in your console, for both protocols:

git config --global https.proxy https://username:password@proxyaddress:port

And, if necessary:

git config --global http.proxy http://username:password@proxyaddress:port`

If you don't know what the proxy and ports are, look for Internet Options (or properties) window menu in your Windows system (Control Panel).

Internet Properties (window)Connections (tab) → LAN Settings (button) → Proxy Server (section) → Advanced (button)

And, remember to replace all values (id est: username, password, proxyaddress, and port) with the actual ones (in proxyaddress you'll have to set up an IP address).

Keep in mind that you may need to leave some of those values empties (because they are not required by your proxy). For example, one time I had to set:

git config --global http.proxy http://:@10.1.33.244:81

As you may noticed, no user name or password were needed.

Useful Bash script

Since I have to set and unset the proxy configuration of my system on a daily basis, I've made this little script you main find useful: Gist

Note

If you need to access GitLab, you may need to follow these steps after the ones I've just described: GitLab authentication requires tokens

When you try to clone the repository, you'll be prompted for your GitLab username and password. Instead of entering your regular password, you need to provide a generated token instead. The username is the same.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
carloswm85
  • 1,396
  • 13
  • 23
  • This gave me a "Unsupported proxy syntax in 'proxyaddress:port'." – Beauregard Lionett Aug 03 '21 at 16:56
  • @LukePerez probably it's a problem specific to your system. If you were the one downvoting the answer, please, remove it. It worked on my system. If it were a wrong solution in deed, we would need more people reporting it is, one case is not enough. Can you provide more information about your problem? That would be useful for finding a solution. – carloswm85 Aug 03 '21 at 21:54
  • @BeauregardLionett Did you replace the words with the actual values? It should be `some ip number for proxy` and `port number`. – carloswm85 Apr 04 '22 at 11:54
  • Probably, I've asked that in August last year though, can't remember now. – Beauregard Lionett Apr 20 '22 at 16:21
  • I remember solving it, can't recall how. – Beauregard Lionett Apr 20 '22 at 16:21
0

I got an error when I used

<git config --global http.proxy http://user:password@proxy_addr:port>

The error is that the configuration file cannot be identified as there isn't any such file. I changed the command to

<git config --system http.proxy http://user:password@proxy_addr:port>

I am running Git on the Windows 7 command prompt. The above command references the configuration file in GIT_HOME/etc/gitconfig. The --global option does not.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kishore Guruswamy
  • 1,901
  • 1
  • 12
  • 5
0

Before you try the fancy stuff, try disabling the firewall and antivirus and see if it works. That was my problem.

Souradeep Nanda
  • 3,116
  • 2
  • 30
  • 44
0

For me, I have to set the https_proxy and http_proxy in addition to the Git proxy configuration. Only then did it work.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
seenukarthi
  • 8,241
  • 10
  • 47
  • 68
0

Being in a corporate environment, "our" Git installation used a gitconfig file in its installation directory, not the standard C:\users\<you>\.gitconfig file.

This showed me where the gitconfig file was:

git config --list --show-origin

I edited the file by adding these:

[remote "origin"]
    proxy = http://proxyserver:port
[http]
    proxy = http://proxyserver:port
[https]
    proxy = http://proxyserver:port

Also, my installation had

[credential]
    helper = manager

I can now get to external repositories.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jeff Blumenthal
  • 442
  • 6
  • 8
0

I am using MSYS2 Git behind a firewall, and this solution works for me:

A very simple solution: replace https:// with git://

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sailfish009
  • 2,561
  • 1
  • 24
  • 31
0

What worked for me is a bit convenient, but none of the previous answers said it:

Solution:

I had to unset both http.proxy and https.proxy

git --global --unset http.proxy
git --global --unset https.proxy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Farhan Ibn Wahid
  • 926
  • 1
  • 9
  • 22
0

I'm also on a company VPN connected to GitHub. I ended up just using GitHub Desktop and that didn’t have any problems.

It is definitely not a fix, but a workaround.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Xopher
  • 496
  • 4
  • 5
-1

I have Git GUI installed on a Windows system behind a proxy. Issuing 'git clone' from a Linux virtual machine running on the Windows system works, but Git GUI yields the 443 error mentioned in the heading.

To fix this, one must edit %USERPROFILE%\.gitconfig to add an [http] section:

[http]
    postBuffer = 1000000000
    proxy = the.proxy.address:the.proxy.port
    sslcainfo = C:/Users/username/Documents/the.certificate.name.cer

Note that the path to the security certificate file has had its backslashes ('\') replaced by slashes ('/').

Urhixidur
  • 2,270
  • 2
  • 19
  • 24
-1

I am using TortoiseGit and simply go to Git in Settings and apply the same settings to Global. Click Apply and OK. It worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Farrukh Chishti
  • 7,652
  • 10
  • 36
  • 60
-1

In Visual Studio, go to menu ToolsNuGet Package ManagerPackage Manager Console.

Type: git config --global http.proxy http://xxx.xxxx.xxxx:Port

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Apollo
  • 1,990
  • 12
  • 44
  • 65
-1

I resolved my issue by changing the DNS name server to 8.8.8.8. (pls note your cause may be different from mine, I just provide the solution to my issue here, may not work for you)

LIU YUE
  • 1,593
  • 11
  • 19
-2

If you are on Windows and not behind a proxy, simply restarting your machine may solve it.