Git push fails - client intended to send too large chunked body
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
With an nginx (nginx version 1.4.7 which includes built-in chunking support) front end, attempting to push to Bitbucket Server over HTTP/S fails with the following error (SSH works without issue):
2014/04/17 11:09:27 [error] 448#0: *334 client intended to send too large chunked body: 1032429+16372 bytes, client: 192.168.152.129, server: bitbucket.bturner.com,
request: "POST /scm/qa/test-huge.git/git-receive-pack HTTP/1.1", host: "bitbucket.bturner.com"
2014/04/17 11:13:43 [error] 599#0: *341 client intended to send too large chunked body: 1032429+16372 bytes, client: 192.168.152.129, server: bitbucket.bturner.com,
request: "POST /scm/qa/test-huge.git/git-receive-pack HTTP/1.1", host: "bitbucket.bturner.com"
2014/04/17 11:15:19 [error] 630#0: *348 client intended to send too large chunked body: 1073733869+8192 bytes, client: 192.168.152.129, server: bitbucket.bturner.com,
request: "POST /scm/qa/test-huge.git/git-receive-pack HTTP/1.1", host: "bitbucket.bturner.com"
Git trace logs while performing push.
The requested URL returned error: 413 Request Entity Too Large
Closing connection 2
error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
Writing objects: 100% (3/3), 1.00 GiB | 228.95 MiB/s, done.
Total 3 (delta 0), reused 1 (delta 0)
packet: git> 0000
fatal: The remote end hung up unexpectedly
Everything up-to-date
Diagnosis
Without the client_max_body_size
on the 443 server entry, pushing dies basically immediately for anything not trivially-sized because the default limit of 1M is applied. By setting client_max_body_size 1024m;
on 443, pushing a 650MB repository succeeds. Pushing a 1.2GB repository fails with the final failure in the output above, where nginx complains about the data being over 1GB.
Resolution
Setting client_max_body_size 0;
allows users to push repositories of any size.
Final configuration (usually the nginx.conf file is placed at /etc/nginx/nginx.conf:
client_body_buffer_size 128k;
client_max_body_size 0;
ignore_invalid_headers off;
proxy_buffer_size 16k;
proxy_buffers 32 16k;
proxy_busy_buffers_size 64k;
proxy_connect_timeout 60;
proxy_intercept_errors on;
proxy_next_upstream error timeout;
proxy_redirect off;
proxy_send_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_temp_file_write_size 64k;
ssl on;
ssl_certificate /etc/nginx/ssl/bitbucket.bturner.com.crt;
ssl_certificate_key /etc/nginx/ssl/bitbucket.bturner.com.key;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!EXP-RC4-MD5:!aNULL:!kEDH;
ssl_prefer_server_ciphers on;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:TLSSL:16m;
ssl_session_timeout 10m;
We found that if client_max_body_size
is set super high and you don't want to lower it, for example:
client_max_body_size 50G;
You might need to switch proxy_request_buffering
off by setting this directive:
proxy_request_buffering off;