104

When l try to use git push, an error reports:

Fatal: fatal: unable to access 'https://github.com/xxx': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

My git version is 2.16.2 for windows

It worked well before this day, and reinstalling git seems to not work.

Can anyone help me with that? Thanks in advance!

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
Rosmee
  • 1,125
  • 2
  • 10
  • 10
  • 4
    Something is blocking the connection to github. It is likely some kind of firewall, either on your machine or in your network. If it works with a browser on same machine then the browser is probably using a proxy and you need to configure git to use this proxy too. – Steffen Ullrich Mar 18 '18 at 07:18
  • 1
    There are already enough information out there which show how to use a proxy with git, like [Getting git to work with a proxy server](https://stackoverflow.com/questions/783811/getting-git-to-work-with-a-proxy-server). If it worked before but does not work now then you need to figure out first what you have changed in your configuration or what has been changed in the network so you can configure the proxy properly. – Steffen Ullrich Mar 18 '18 at 07:27
  • Could you do `where git` and `git --version` to verify that an old version is not in the path before the new one you installed? Because a version >2.16 should be used since github invalidate some security communication protocols 1 or 2 weeks ago... – Philippe Mar 18 '18 at 10:21
  • @Philippe `where git` = `F:\Git\mingw64\bin\git.exe F:\Git\cmd\git.exe ` and `git --version` = `git version 2.16.2.windows.1 ` – Rosmee Mar 18 '18 at 11:23
  • should l switch to previous version? – Rosmee Mar 18 '18 at 11:39
  • It seems good. You could try some previous version (it's a good thing to investigate! ) if you want but stay > v2.16.0 – Philippe Mar 18 '18 at 13:46
  • I am getting the same error when I am using VS-2019, I am behind office network and do not have any git bash or git tools installed. Can anybody give the solution. – karunakar bhogyari Dec 19 '19 at 07:58
  • If you are in China, open global agent, do not use PAC. – Huaiyu Huang May 16 '21 at 03:05
  • have this problem cause i didnt connect to vpn of my compnay – Vladi Jul 28 '22 at 08:06

10 Answers10

121

If you are behind a proxy, try the following:

git config --global --add remote.origin.proxy ""
Kim
  • 4,080
  • 2
  • 30
  • 51
mahesh adepu
  • 1,242
  • 1
  • 8
  • 3
48

After reinstalling Git did nothing, I found an issue on GitHub that helped me solve it.

In your terminal run this command first:

git config --global http.sslBackend "openssl"

Then this one:

git config --global http.sslCAInfo "C:\Program Files\Git\mingw64\ssl\cert.pem"

You may need to change your path depending on where you have it installed.

Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38
  • 16
    I just ran `git config --global http.sslBackend "openssl"` and it allowed me to push. – gwalshington Jul 20 '18 at 02:14
  • 3
    same here on a MacOS, ' git config --global http.sslBackend "openssl" ' helped me already. – novski Jul 20 '18 at 08:08
  • 6
    Setting `sslVerify` to false is dangerous and effectively defeats the purpose of HTTPS/SSL. – vcsjones Jul 20 '18 at 12:24
  • 2
    I just ran the first command and it worked. I was having the issue while pushing data to repo – Nikhil Redij Feb 19 '19 at 13:41
  • 2
    Worked for me. I love how getting anything done in git requires me to spend half my life learning incomprehensible magic commands. – Neutrino Sep 16 '20 at 12:00
  • This worked great, then stopped. Had to close secondary instances of Android Studio before it started to work again. Bit obscure but may help. – Nick Wright Sep 21 '20 at 17:02
  • That makes absolutely no sense. OpenSSL is the one throwing the error so it's already configured. – eco Sep 07 '22 at 15:37
27

Opening a new terminal session worked for me

Omar
  • 2,726
  • 2
  • 32
  • 65
14
git config --global --add remote.origin.proxy "127.0.0.1:(proxy http port number)"

in ch

enter image description here

add image @afder cc's

black_pearl
  • 2,549
  • 1
  • 23
  • 36
13

if your using proxy try to go to run and enter inetcpl.cpl then connections then Lan settings then advance and now you see your proxy, use the http one.

then open Git Bash then enter this command

$ git config --global http.proxy 

if theres no output of it then the proxy in Git Bash is not set then set it with these command and use proxy and port shown in the 1st paragraph

$ git config --global http.proxy proxyaddress:port

then enter this command again

$ git config --global http.proxy 

and there you go it is set

to reset the proxy on Git Bash just enter this command

 $ git config --global --unset http.proxy 

i was also having these problem lately i was using psiphon vpn on desktop as a newbie it was also hard to find this solution glad i could help. :)

The OuterSpace
  • 151
  • 1
  • 4
6

Sometimes, it can be simply because your system was unable to connect to GitHub, possibly because you were not connected to the Internet (or you had a lousy connection).

(It's true - this problem can be reproduced. Just disconnect your LAN/WiFi and then do git pull, you will get the same error).

PS: This happened with me. Sometimes the problem is your internet connection rather than configs.

Pranav Totla
  • 2,182
  • 2
  • 20
  • 28
  • Worked for me. Close internet connection - reconnect and restart IDE – Tim Maes Jan 14 '21 at 08:20
  • This worked for me. I had to physically disconnect my LAN cord and reconnect it. I have a backup connection via Wi-Fi and it probably got a new IP address from there. No issues doing any git commands after. – kobowo Mar 17 '22 at 15:57
4

I solved this same problem changing the git url in 'clone' step - use SSH instead of HTTPS link.

  • 1
    you helped, i tried all of solutions mentioned above, the only one solved my problem is yours. – paul cheung Nov 01 '20 at 11:26
  • I did it from the suggestions above for the first time and I got one error again. But I saw your answer and I did it with SSH again, and now it is fixed. Thanks:) – Arman Ebrahimi Jan 07 '23 at 14:11
3

I recently installed git 2.24.1 and not sure what changes I made, but it was not allowing me to clone or push without admin account on my machine.

This solved my issue:

  1. In your terminal run this command first:

    git config --global http.sslBackend "openssl"
    
  2. Then this one:

    git config --global http.sslCAInfo "C:\Program Files\Git\mingw64\ssl\cert.pem"
    
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Ashish
  • 999
  • 6
  • 4
  • 1
    How is this answer different from https://stackoverflow.com/a/51433565/1710392 which was posted 2 years before? – Étienne Jan 11 '21 at 12:22
2

For Shadowsocks users:

  1. Click the Shadowsocks icon, go Preferences:

enter image description here

  1. Suppose that your local proxy listen port is XXX, run this:
git config --global --add remote.origin.proxy "127.0.0.1:XXX"
K. Symbol
  • 3,330
  • 1
  • 21
  • 22
1

I tried many answers and it still failed with the same error, including the following one:

git config --global http.sslBackend "openssl"

However, I tried reverting that by:

git config --global --unset-all http.sslBackend

then restart my laptop, and everything started working again.

I'm not exactly sure what went wrong initially, but lesson learned is that the correct config isn't the same for everyone.

Bob Gong
  • 36
  • 4