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. Fatal error: Uncaught Error: Call to undefined function ereg() in /var/www/html/wp-content/themes/thematic/library/extensions/comments-extensions.php:262 Stack trace: #0 /var/www/html/wp-content/themes/thematic/library/extensions/discussion.php(30): thematic_commenter_link() #1 /var/www/html/wp-includes/class-walker-comment.php(180): thematic_comments(Object(WP_Comment), Array, 1) #2 /var/www/html/wp-includes/class-wp-walker.php(146): Walker_Comment->start_el('', Object(WP_Comment), 1, Array) #3 /var/www/html/wp-includes/class-walker-comment.php(140): Walker->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #4 /var/www/html/wp-includes/class-wp-walker.php(371): Walker_Comment->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #5 /var/www/html/wp-includes/comment-template.php(2040): Walker->paged_walk(Array, '5', 0, 0, Array) #6 /var/www/html/wp-content/themes/thematic/comments.php(80): wp_list_comments('type=comment&ca...') #7 /var/www/html/wp-includes/comment-template.php(1430): require('/var/www in /var/www/html/wp-content/themes/thematic/library/extensions/comments-extensions.php on line 262