Bitbucket Data Center: git push "error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413"
HTTP 413 is "Request Entity Too Large": a server refused a request because its body was bigger than the limit. With Bitbucket Data Center behind nginx, that server is nginx, whose default limit for a request body is 1 MB, so small pushes work and larger ones fail. The fix is one line in the nginx configuration, made by whoever runs the proxy. Pushing over SSH is not affected, which also makes a quick test.
What it looks like
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 fatal: the remote end hung up unexpectedly
Atlassian's article on this shows the older wording, RPC failed; result=22, HTTP code = 413, and the line in nginx's own error log: client intended to send too large chunked body. A push that fails every time whatever its size is a different problem (see the last section).
Pushes go through Git, not through the IDE's review list: Pull Request Inbox for Bitbucket, a plugin for JetBrains IDEs, reads and changes pull requests with small REST requests, so it keeps working while a large push is refused.
1. Confirm it is the proxy
Ask Git to print what the server answers, in PowerShell:
$env:GIT_CURL_VERBOSE = 1 git push origin <branch>
On macOS and Linux: GIT_CURL_VERBOSE=1 git push origin <branch>. Look for 413 in the answer. The nginx documentation says that when a request body exceeds client_max_body_size, nginx returns 413 itself, so Bitbucket never sees the push. A push of a small change succeeding while a large one fails points the same way. If pushing over SSH works, the Bitbucket server is fine and the problem sits in the HTTP path.
2. Raise the limit in nginx
For whoever runs the proxy. client_max_body_size may be set in http, server or location; its default is 1m, and the nginx documentation says setting it to 0 disables the check. Atlassian's article puts it in the HTTPS server block that proxies to Bitbucket:
server {
# the existing lines of the HTTPS server for Bitbucket stay as they are
client_max_body_size 0;
}
Atlassian reports that a fixed 1024m let a 650 MB push through and still refused a 1.2 GB one, and that if you keep a very high fixed limit instead of 0, you should also set proxy_request_buffering off;. nginx's documentation says that with it off, the body goes to the proxied server as it arrives instead of being read in full first. Then apply it. The nginx beginner's guide says a change takes effect only after the reload signal, and that nginx checks the syntax and keeps the old configuration if the new one is invalid:
nginx -s reload
Another reverse proxy, a load balancer or a web application firewall has its own request-size limit; look for its setting in its own documentation.
3. Not this: http.postBuffer
Raising http.postBuffer is a common tip. The Git documentation says that raising it is only effective for disabling chunked transfer encoding, and its default of 1 MiB is "sufficient for most requests". It does not change the size of what the server accepts, so it does not lift an nginx limit. Use it only for what the Git documentation says it is for.
4. Check
Push again with the verbose output on. The 413 is gone when the limit is high enough, and Bitbucket's own answers appear: a rejection by a hook ("pre-receive hook declined") or by the sign-in (HTTP access token with Git). If instead the push still dies without a 413, Atlassian's list of other causes for a failing push over HTTPS includes a crash of the Bitbucket process, a proxy timeout and the network configuration.
In the IDE
In a JetBrains IDE, push runs your command-line Git, so the 413 above appears in the IDE's Git output the same way. Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, works with Bitbucket Data Center 8.9 or later in beta. It uses the Data Center REST API with a personal HTTP access token that the IDE keeps in its password safe and sends only to that server, so a limit on the size of a push does not touch it. When something between the IDE and the server answers with a web page instead of Bitbucket's own answer (a proxy, a VPN or a sign-in gateway), it says so rather than reporting a refused token. The review inbox, diffs and discussions are free; approving, commenting and merging are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Sources
- Git push fails - client intended to send too large chunked body (Atlassian)
- client_max_body_size and proxy_request_buffering (nginx documentation)
- Beginner's Guide: reloading the configuration (nginx documentation)
- git-config: http.postBuffer (Git documentation)
Bitbucket and Atlassian are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.
More: "pre-receive hook declined" · "Received HTTP code 407 from proxy" · Data Center: HTTP access token with Git · 日本語