Last Updated:
Problem Overview |
Reproducing the Problem |
Possible Solutions |
HTTPS vs. SSH |
Using HTTPS Proxy |
Using SSH |
Conclusion |
Recently, I've encountered an issue when using Git. Whenever I try to perform operations that require access to remote repositories, such as , Git fails to connect to the GitHub server, resulting in the error. This error was quite frustrating.
System Version: macOS Big Sur 11.2.3
Tool: Terminal
Command: $git clone https://github.com/xxx/xxx.git
Error: fatal: unable to access 'https://github.com/xxx/xxx.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
After researching and trying several solutions, I've compiled the following:
As we all know, restarting solves 90% of problems. Sometimes, restarting can directly resolve the issue. This method didn't work for me.
You can modify your Git settings as follows:
Remove HTTP / HTTPS proxy settings:
You can directly modify the global Git configuration file:
$vim ~/.gitconfig
Remove the relevant HTTP / HTTPS proxy settings.
You can also use the following commands:
$git config --global --unset http.proxy
$git config --global --unset https.proxy
This method didn't work for me.
Since the error is related to the LibreSSL library, you can configure Git to use the OpenSSL library for HTTPS communication:
$git config --global http.sslBackend "openssl"
This method didn't work for me.
Due to the use of IPv6, this issue might occur. You can configure your computer not to use IPv6:
$networksetup -setv6off Wi-Fi
If needed, you can revert the configuration:
$networksetup -setv6automatic Wi-Fi
This method seemed to work for me.
Updated: 2021.07.11
After trying so many online solutions, I couldn't find the root cause. The root cause is the restrictions on external servers in the domestic network environment. Only by resolving this can you avoid the network errors of git clone/push/pull.
I am providing solutions for both HTTPS and SSH, depending on the user's preferred connection method.
Generally, these two methods don't have many differences. But in an environment with firewalls or proxies, using SSH may be restricted. According to GitHub's official documentation:
You can work with all repositories on GitHub over HTTPS, even if you are behind a firewall or proxy.
You can work with all repositories on GitHub over SSH, although firewalls and proxys might refuse to allow SSH connections.
Fortunately, under the condition of firewall port restrictions, users can use HTTPS ports to connect to GitHub services via SSH. For details, please refer to Using SSH over the HTTPS port.
When using HTTPS to connect to GitHub to perform git clone/push/pull (i.e., the address of the remote repository (usually origin) is https://github.com/xxx/xxx.git), you need to modify your local Git settings to use a proxy to make requests to GitHub.
Requirements: You need a proxy. Search for relevant information on how to get a proxy. (Due to policy reasons, I provide a few keywords: airport, FreeWhale, Meet)
Run the following command:
$git config --global -e
This will enter the Git configuration file editing interface (it will open the default editor set by Git, usually Vim or Nano).
In this file, add the following content:
[http] proxy = socks5://127.0.0.1:7891
[https] proxy = socks5://127.0.0.1:7891
In this, 7891 is the port specified by your proxy software. Please modify it based on your actual situation.
This method worked for me.
Updated: 2022.12.07
Considering GitHub's current service quality issues in the domestic environment, this method may fail in the future. But before that, it is still the simplest and most effective method.
As we all know, git clone can use HTTPS or SSH. Since HTTPS may be restricted by the network environment, while SSH does not have these restrictions, we might as well change the communication protocol between the local Git and GitHub from HTTPS to SSH.
Requirements: You need to generate an SSH key pair in advance and add the public key to your GitHub account. For detailed information, please refer to Connecting to GitHub with SSH.
Enter the corresponding repository directory and run the following command:
$git remote set-url origin git@github.com:xxx/xxx.git
After the modification is complete, you can use the following command to check the current origin address:
$git remote -v
This method worked for me. Highly recommend this method, simple and convenient.
Sometimes, online solutions may not solve your own problem, and you need to conduct in-depth research and exploration.
SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Switching remote URLs from HTTPS to SSH