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

I used git "push" and "pull" commands with success till yesterday, but today it is not working and give me this error: Push failed: Unable to access 'https://github.com/username/repository.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

I tried many solutions but no success. Solutions I tried:
1. Using SSH key
2. Updating git
3. Installing curl with openssl (same error while installing)

This is the result of curl github.com -v:

* Rebuilt URL to: github.com/
*   Trying 192.30.253.112...
* TCP_NODELAY set
* Connected to github.com (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: github.com
> User-Agent: curl/7.54.0
> Accept: */*
> 
* Recv failure: Connection reset by peer
* stopped the pause stream!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer


Solution 1:[1]

The problem was solved by restarting my computer.

Update:
Kaspersky Internet Security/Antivirus causes the problem and disabling/removing it fixes the issue for most users.

Solution 2:[2]

We started an investigation internally and we discovered that in our case was a problem with Kaspersky antivirus.

We raised a bug for their support, waited, waited, got feedback that would be solved some months ago in a new release. We got and tried the release, the problem was still there. We raised again another ticket, a lot of debugging information/files they requested. Still not solved.

We gave up and moved to Avast, no problems so far.

Solution 3:[3]

As commented in libressl-portable/portable/issue 369

I update with brew, libressl, openssl and curl and reboot my machine. It's now working.

Note that SSH should work, but for that you need to change your origin URL

git remote set-url origin [email protected]:aUser/aProject

That would not use HTTPS at all then.

Solution 4:[4]

I encountered the same problem, by restarting my Mac, i could push my code to Github and the error message was gone.

Solution 5:[5]

Most likely a issue with you network connection. Try to clone the repo using git command and check if that's successful.

eg:

git clone https://github.com/firebase/firebase-ios-sdk.git

Solution 6:[6]

Try export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087; if you are using a proxy (Change the value for your own need).

Solution 7:[7]

In my case, the new git repo is just created and I do push some code and then get this issue. I try to run git pull first and run git push after that. Then everything works well, didn't get the root cause. Operation: macOS Monterey

Solution 8:[8]

Try to use brew mirror site(s) instead of Github.

For example, I am in China and I constantly fail to visit Github with that error, but I know some brew mirror site like https://mirror.tuna.tsinghua.edu.cn/help/homebrew/

So I raised an issue against brew Provide an easy way to change homebrew's origins. They fixed it in 2.3, so set mirror like these,

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Rodrigo Farias Rezino
Solution 3 VonC
Solution 4 Merouane T.
Solution 5 Adolf Dsilva
Solution 6 Lane
Solution 7 Phi Nguy?n
Solution 8 Qiulang