124

I use Ubuntu 16.04. When I want to git push origin master I get:

error: RPC failed; curl 56 GnuTLS recv error (-12): A TLS fatal alert has been received.
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
4
  • 2
    I don't know what happened, but I set the output to be more verbose, and somehow it worked. export GIT_TRACE_PACKET=1; export GIT_TRACE=1; export GIT_CURL_VERBOSE=1 It probably has nothing to do with it, but it may be helpful to look in the verbose output so you can pinpoint the issue.
    – dayuloli
    Aug 24, 2016 at 9:57
  • 2
    similar issue. error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull Sep 12, 2017 at 5:11
  • please refer to this link, he's the hero. stackoverflow.com/a/52530617/794765
    – Robert
    May 5, 2021 at 8:10
  • @dayuloli: do you set these value to default values? :( I have so many trace output now
    – Amir
    Jun 19 at 21:14

35 Answers 35

119

The accepted answer from @harlequin might work, but I spend 2 hours and could not build git package from source code.

However, Check the below link as this works for me.

The remote end hung up unexpectedly while git cloning

just update the http post buffer value

git config --global http.postBuffer 1048576000
git config --global https.postBuffer 1048576000
4
  • 3
    I had to restart my system to make this work Oct 31, 2021 at 15:49
  • 1
    I just opened GIT Extensions cmd and executed line showed by Shubham, then push made from Visual Studio worked perfectly! Thxs!
    – David
    Feb 1, 2022 at 8:55
  • 7
    HTTPS in my case, so do this, too: git config --global https.postBuffer 1048576000 Jun 22, 2022 at 9:38
  • There is no https section in git config, and thus no https.postBuffer setting. (Yes you can add it, it just won't do anything. See git-scm.com/docs/git-config.
    – Ikke
    Sep 13 at 17:33
41

After reading your posts, I solved it simply by

apt install gnutls-bin
3
  • I got the same issue with same solution (installing gnutls-bin) on debian 9.11 stretch.
    – Honza
    Nov 1, 2019 at 20:32
  • 6
    This doesn't fix the problem for me Mar 6, 2021 at 10:15
  • works for me, guys I have to bookmark this one
    – http8086
    Sep 10, 2021 at 5:08
37

To solve this issue:

Rebuilding git with openssl instead of gnutls fixed my problem.

I followed these instructions

7
  • 12
    the whole process may take ~ 1hour
    – XoXo
    Jan 26, 2017 at 1:13
  • 3
    On Ubuntu 16.04 took around 10mins! For step 7, after removing the line "TEST=test" in debian/rules, I also changed NO_OPENSSL=0 in the OPTS and in step 8, added "-uc -us" for not signing the package. Nov 21, 2017 at 23:36
  • I have the same error when performing git clone, and this solution saved me!
    – skyuuka
    Sep 8, 2018 at 0:51
  • I get error: RPC failed; curl 18 transfer closed with outstanding read data remaining as one of the people commenting at the end of the article you linked. I confirm that removing tests spare a lot of time, while -uc -us was needed to make a custom package. However, I haven't tried NO_OPENSSL=0 yet... For now I'm satisfied with my workaround (posted as answer).
    – hsandt
    Jan 31, 2019 at 22:38
  • do you have any short-solution for Ubuntu-18? or this above will work? Apr 10, 2020 at 14:36
31

I have a workaround if you need to clone or pull and the problem lies in the size of the repository history. It may also help when you want to push later, with no guarantee.

Simply retrieve the last commits with --depth=[number of last commits].

You can do this at clone time, or, if working from a local repository to which you added a remote, at pull time. For instance, to only retrieve the last commit (of each branch):

git clone repo --depth=1
# or
git pull --depth=1

UPDATE: if the remote is getting too much ahead of you, the issue may come back later as you try to pull the last changes, but there are too many and the connection closes with curl 56. You may have to git pull --depth=[number of commits ahead on remote], which is tedious if you're working on a very active repository.

5
  • 1
    For those for which this workaround worked: maybe your Internet connection doesn't support long TLS connections for some reason. I changed provider / increased bandwidth and I don't need the workaround anymore (see stackoverflow.com/a/59426260/3256073)
    – hsandt
    Dec 20, 2019 at 13:48
  • when I put --depth=1, the error will not come. But I need all the commits. What to do? Jan 21, 2020 at 13:09
  • You can try to pull incrementally higher and higher depth... Not sure if that will avoid having too long connections. If the issue comes from your connection, you can also clone the repo from a different place, put it on a USB key, bring it home, copy it back on your computer. And from here, make sure to regularly pull so you don't have to download too much at once... (yes, I really did that before I could change provider, and it worked)
    – hsandt
    Jan 21, 2020 at 21:52
  • This solved my issue when cloning large git repos (specifically bootstrap and Font-Awesome) from within WSL2. Thanks.
    – Inyoka
    Oct 30, 2020 at 9:02
  • @hsandt is a saviour Sep 15 at 13:24
19

You can set some option to resolve the issue

Either at global level: (needed if you clone, don't forget to reset after)

$ git config --global http.sslVerify false
$ git config --global http.postBuffer 1048576000

or on a local repository

$ git config http.sslVerify false
$ git config http.postBuffer 1048576000
3
  • 9
    turning off sslVerify doesn't sound secure?
    – jmunsch
    Nov 21, 2019 at 0:56
  • worked for me! :)
    – Hugo Abreu
    Sep 21, 2021 at 18:04
  • 5
    Rather than turning off SSL, make the same postBuffer change for HTTPS: git config --global https.postBuffer 1048576000 Jun 22, 2022 at 9:40
9

I also encountered same and restart of the system resolved it :)

2
  • 1
    what do you mean? A simple reboot? Oct 27, 2020 at 5:30
  • @KansaiRobot I assume you have this sorted by now. However, for anyone else wondering the same, yes, a simple reboot of my local machine resolved this issue for me. Jan 6, 2021 at 11:40
8

I am also using Ubuntu based system (Mint mate 18), got the similar issue when clone large repo from github.

The simple solution worked for me is to use ssh protocol instead of http(s) protocol.

e.g

git clone [email protected]:xxx/yyy.git
0
7

WSL2 users getting this with Ubuntu 18, see this issue. Basically you need to update your wireless driver.

Ok. So updating my wifi chipset drivers fixed the issue. In case anyone else runs into the above, the drivers i updated to were found here: https://downloadcenter.intel.com/download/28794/Windows-10-Wi-Fi-Drivers-for-Intel-Wireless-Adapters?product=99446

0
5

Try to upgrading openssl modules

I solved it by doing that

sudo apt install openssl
1
  • This is the solution for me!! Thanks!!
    – jungwook
    Jan 17, 2022 at 2:03
5

I saw similar issues (particularly with depth) on some legacy projects when we were cloning that used to live on TFS. Enabling long paths resolved our issue and may be something else worth trying.

git config --system core.longpaths true
4

For Linux: Simple you can run below commands:

1) git config -l
2) git config --global http.postBuffer 524288000
        Or set double value  1048576000
3) git config --global https.postBuffer 
4) git config --global core.compression -1 
5) service apache2 restart

Then again check the config of git

git config -l

now you can run clone command

git clone yourrepo

I hope this will be solved the issue.

1
  • My problem was that I didn't have the apache2 server installed. The answer helped me out to find that. Sep 25, 2022 at 23:22
3

I faced this issue on Ubuntu 18.04 when cloning CppCheck using https.

A workaround to it was to use http instead.

3

I solved this problem by disconnecting my VPN (My OS is ubuntu-16.04).

2

All I did was disconnect and reconnect my pc from the wifi and it worked. Sometimes the answer might be very simple. Mine works now

1

Check your Network is properly working...this problem also occures because of internet issues

1
  • I spent almost 2 hours and then figure out that it is actually due to slow internet ><
    – Afzal Ali
    May 23, 2022 at 9:23
1

I just managed to solve this by cloning using SSH.

To do that I had to add my machine's SSH key to my account.

1

Additionally,this error may occurs in you are using any proxy in command line.

if you export any proxy before , unset it .

$ unset all_proxy && unset ALL_PROXY
1

Try to disable your IPV6 for that and disable after. I think this is your problem.

1
  • this worked for me today
    – VeteranLK
    May 14 at 20:27
1

I solved it by just running single command

apt upgrade (being root user)

1

If all answers above are not working for you, you should check if you've enabled any kind of proxy before :

git config --global http.proxy ""
1
  • thx I had to use git config --global --unset https.proxy and git config --global --unset http.proxy Jan 17 at 11:04
1

In my case

git config --global http.sslBackend openssl

fixed the issue

0

Another way here:please try it again, sometimes it happen just result from your network status.

My situation is as below.

enter image description here

0

I tried all the above without success. Eventually I realised I had a weak WiFi connection and therefore slow download speed. I connected my device VIA Ethernet and that solved my problem straight away.

0

I got this error while i tried to push a new branch upstream

git push --set-upstream origin xyz

I tried almost all of the git config edits suggested above including a system reboot. Nothing worked.

So I went back to master and did a pull, went back to my xyz branch, did a merge with master and was able to push.

* currently on branch xyz
git checkout master
git pull
git checkout xyz
git merge master
git push --set-upstream origin xyz

I have to say nothing in master conflicted with any of my changes in my new branch "xyx". Only a couple of new commits from master were merged to my "xyz" branch. This shouldn't have been a problem on normal days.

0

I met the same question, and solved it by using SSH protocol.

git clone [email protected]:micro/micro.git
0

Had the same problem hosting Go Git Server behind nginx and cloning:

remote: Enumerating objects: 103, done. remote: Counting objects: 100% (103/103), done. remote: Compressing objects: 100% (47/47), done. remote: Total 103 (delta 52), reused 99 (delta 51), pack-reused 0 Receiving objects: 100% (103/103), 11.56 KiB | 1.16 MiB/s, done. Resolving deltas: 100% (52/52), done. error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.

After searching RPC based issues, there appears to he a requirement to use HTTP2

Therefore this line in my nginx site configuration:

listen 443 ssl; # managed by Certbot

Was changed to this, to enable http2 - which is not a default:

listen 443 ssl http2; # managed by Certbot

And TLS in general seems happier (i.e. I had other errors regarding curl and TLS, when inspecting verbose output)

I have verified this as a root cause by removing http2, which reproduces the error and reinstating http2 resolves the problem.

0

I had a similar fault:

error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.

when trying to clone a repository from Github.

After trying most of the solutions posted here, none of which worked, it turned out to be the parental controls on our home network. Turning these parental controls off solved the problem.

0

If you are are running the git server service, then rather than it be a git client issue ... perhaps it's a git server issue too ! This is what the solution was for me...

We were running a gitbucket server with a front-end nginx reverse proxy for https.

Following a major system OS version upgrade, we started getting this error across all git clients. Turns out that nginx got replaced and the new package's default nginx.conf got installed. The default nginx user 'www-data' was NOT what it used to be.

Somewhere underneath it all, there must have been a permissions issue, because resetting the nginx user back to it's former value, and restarting nginx got everything going again. .... go figure ! (Yes I had restarted nginx many times prior to the one singular change that solved it)

0

I am facing the same issue since yesterday, but now successfully solved that issue.

First, remove the git package and any other dependent package

$ sudo apt-get remove git

and then install git

sudo apt-get install git-all
0

In my case the problem was that i was using the https instead of the git protocol. In my config file I forced git to use https.

[url "https://"]
        insteadOf = git://

By removing this from my config I was able to clone the required repository.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.