Git “broken pipe” error when pushing to a repository

This is one that’s caught me out on more than one occasion now, hopefully by blogging it I won’t forget about it again quite so soon…

When attempting to push to a git repository over HTTP, you may experience a “broken pipe” error along the lines of the following:

Counting objects: 14466, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3746/3746), done.
error: RPC failed; result=22, HTTP code = 400
fatal: The remote end hung up unexpectedly
Writing objects: 100% (14466/14466), 104.13 MiB | 31.34 MiB/s, done.
Total 14466 (delta 10927), reused 13812 (delta 10474)
fatal: The remote end hung up unexpectedly
fatal: expected ok/error, helper said '2004�Ȍ/↓/Ɠyb��Nj}↑z��"#7‼.m���+x9`>��☼�uhh_������м5���§��z���W?�^&��͙mQM��a`Q�C���Z'

fatal: write error: Broken pipe

This error occurs when the amount of data you’re trying to push in one go exceeds git’s http post buffer which is defined in the docs as:

Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.

Whilst most day to day pushes are likely to be under 1MB, if you’re pushing a large repository over HTTP for the first time, there’s a good chance you’ll exceed this limit, resulting in the above error.

Increasing the buffer is a simple config change to set the new size in bytes (a value which will obviously need to exceed the size of the push that’s erroring):

git config http.postBuffer 209715200

One more thing – even after increasing git’s buffer I was still getting fatal errors. If you also host the destination repository, you need to make sure the server it’s running on doesn’t have a limit to the size of POST requests it will accept – a configuration change may be required to that as well. After I bumped up my max request length, everything worked as expected.

This entry was posted in Fixes and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

28 Comments

  1. Brent McCullough
    Posted September 8, 2011 at 8:59 pm | Permalink

    There is no +1 button, so I will just say “thanks.” Save me lots of time – just not all of my hair :\.

  2. Posted September 20, 2011 at 11:04 am | Permalink

    Thanks for this. Worked for me importing a current repository to Github.

    🙂

  3. Ramiro Batista da Lu
    Posted November 23, 2011 at 6:51 pm | Permalink

    Thank you very much, worked for me.

  4. Posted April 17, 2012 at 10:36 am | Permalink

    Great post… I was stumbling on this issue and this was the right answer to my problem.

    Many thanks
    Bye
    Piero

  5. Hemadri
    Posted June 11, 2012 at 11:34 am | Permalink

    Great post… I was struggling on this issue and this was the right answer to my problem.

  6. Posted June 19, 2012 at 5:55 am | Permalink

    Thanks a ton! I was also struggling with this issue on a git repository while doing git push on new mac. You saved my day!

  7. Fred
    Posted July 25, 2012 at 9:43 pm | Permalink

    Congrats man !!!

    Saved loaaaaads of time !!

    Cheers,

  8. niahoo
    Posted October 2, 2012 at 12:43 pm | Permalink

    thanks too

  9. pfraces
    Posted October 29, 2012 at 3:18 am | Permalink

    thanks!

  10. Posted November 23, 2012 at 12:01 am | Permalink

    Thank you very much! It works like a charm.

  11. Midnightghost
    Posted November 23, 2012 at 8:24 pm | Permalink

    thank you!

  12. Bianka
    Posted February 1, 2013 at 12:28 pm | Permalink

    Thanks for posting this, it helped me alot! @–>–

  13. Posted April 12, 2013 at 4:47 am | Permalink

    Thanks – helped me when I ran into this exact error! I linked to this post from mine about migrating perforce repos to git.

  14. Lahiru
    Posted May 3, 2013 at 7:21 am | Permalink

    Thanks a lot bro…

  15. Praj
    Posted July 1, 2013 at 4:09 pm | Permalink

    Thanks a lot.
    Solved my problem where I spend more than 1 hour 😉

  16. Posted September 24, 2013 at 8:01 pm | Permalink

    This is really annoying! If I’d known this would be an issue, I’d have added files in groups!

    To help Google out, here is my exact error message, as it differs from yours:

    $ git push
    Unable to rewind rpc post data - try increasing http.postBuffer
    error: RPC failed; result=65, HTTP code = 0
    fatal: The remote end hung up unexpectedly
    Everything up-to-date
    $ git config http.postBuffer 209715200
    $ git push
    error: RPC failed; result=56, HTTP code = 0
    fatal: The remote end hung up unexpectedly
    Everything up-to-date

    Bah!

    • Posted February 6, 2014 at 8:15 pm | Permalink

      When you deal git with huge files then need to increase buffer size


      $ git config http.postBuffer 524288000

      Example sets postbuffet to 500 MB.

  17. Josh Vieira
    Posted February 4, 2014 at 10:32 pm | Permalink

    Even in 2014, this advice is working great. Though Windows doesn’t refer to the error as a “broken pipe”, the fix works all the same. Thank you for taking the time to post this!

  18. Posted March 18, 2014 at 6:16 pm | Permalink

    Hi Luke!

    I had this same issue, but the post trick didn’t work for me. I figured out that the real problem was that my branch was too far behind the master’s head. So what ended up fixing it was a “git checkout master && git pull && git checkout mybranch && git rebase master && git push -f”. (the git push -f might not be appropriate for all workflows, but happened to be okay for mine.)

    Best,
    Travis

  19. Posted April 8, 2014 at 3:52 pm | Permalink

    I could not resist commenting. Very well written!

    Also visit my weblog … adobe

  20. Posted April 15, 2014 at 1:02 pm | Permalink

    I am curious to find out what blog system you’re utilizing?
    I’m experiencing some minor security issues with my latest
    website and I would like to find something more risk-free.
    Do you have any recommendations?

    Here is my website; homemade pregnancy test

  21. Posted April 15, 2014 at 3:59 pm | Permalink

    Hey would you mind letting me know which web host you’re using?
    I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot quicker then most.
    Can you recommend a good internet hosting provider at a reasonable price?
    Thanks a lot, I appreciate it!

    Feel free to surf to my web site engagement party ideas

  22. Jason
    Posted May 1, 2014 at 2:45 pm | Permalink

    Life saver!

  23. AJ
    Posted July 7, 2014 at 10:33 pm | Permalink

    Does this setting solve the same problem when using SSH instead of HTTP?

  24. Posted November 5, 2015 at 2:48 pm | Permalink

    Thanks a lot. It worked.

  25. Posted March 11, 2016 at 10:59 pm | Permalink

    Thanks for this, it did save me time.

  26. Posted July 19, 2016 at 1:04 pm | Permalink

    Thank you, man!

  27. Posted November 29, 2017 at 5:10 am | Permalink

    Thank you very much. It saves my day

9 Trackbacks

Leave a Reply