How to solve 'gnutls_handshake() failed' error when doing 'git clone' from github.com ?
1. Purpose
In this post, I will demonstrate how to resolve the following error when doing git clone
:
root@launch-advisor-20191120:/opt# git clone https://github.com/boylegu/SpringBoot-vue.gitCloning into 'SpringBoot-vue'...fatal: unable to access 'https://github.com/boylegu/SpringBoot-vue.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.root@launch-advisor-20191120:/opt#
The core error message is:
fatal: unable to access 'https://github.com/boylegu/SpringBoot-vue.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
2. The environment
- Ubuntu 18.04.5 LTS
- Git version:git version 2.17.1
3. The solutions
What does the error mean? Here is an answer from bk2204 :
So, this problem is caused by the HTTPS/TLS/SSL , so the solution are as follows:
3.1 Solution #1
The simplest solution is to use http
instead of https
when doing git clone
:
Replace:
git clone https://github.com/boylegu/SpringBoot-vue.git
with this:
git clone http://github.com/boylegu/SpringBoot-vue.git
Now run the command:
root@launch-advisor-20191120:/opt# git clone http://github.com/boylegu/SpringBoot-vue.gitCloning into 'SpringBoot-vue'...warning: redirecting to https://github.com/boylegu/SpringBoot-vue.git/remote: Enumerating objects: 503, done.remote: Counting objects: 100% (15/15), done.remote: Compressing objects: 100% (15/15), done.remote: Total 503 (delta 6), reused 0 (delta 0), pack-reused 488Receiving objects: 100% (503/503), 32.34 MiB | 15.97 MiB/s, done.Resolving deltas: 100% (151/151), done.root@launch-advisor-20191120:/opt#
It works!!!
3.2 Solution #2
Turn off the https verification:
git config --global http.sslVerify false
It will work if your git server uses a self-signed certification.
3.3 Solution #3
Recompile the local git version with ssl: (Remember to replace 1.7.9.5
with the actual version of git in your system.)
sudo apt-get updatesudo apt-get install build-essential fakeroot dpkg-devsudo apt-get build-dep gitmkdir ~/git-opensslcd ~/git-opensslapt-get source gitdpkg-source -x git_1.7.9.5-1.dsccd git-1.7.9.5
Now It’s working!
4. Summary
In this post, I demonstrated how to resolve the git clone error, you can try the methods as me. I recommend to use the solution #1, it’s simple. That’s it, thanks for your reading.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Git with HTTPS or SSH
- 👨💻 Git protocols
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!