error: RPC failed result=22 - Push to Bitbucket Server fails

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When pushing a large repository into Bitbucket Server, the following outputs might appear after the git push:

Counting objects: 9554, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5064/5064), done.
Writing objects: 100% (9554/9554), 2.79 GiB | 694.00 KiB/s, done.
Total 9554 (delta 4382), reused 9554 (delta 4382)
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
POST git-receive-pack (33737128 bytes)

fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

error: RPC failed; result=22, HTTP code = 413

Diagnosis

To turn on Git debug logging, before pushing using the command line, proceed like that for different OS:

On Linux

Execute the following in the command line before executing the Git command:

export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

On Windows

Execute the following in the command line before executing the Git command:

set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1

Possible causes

  • When pushing a large amount of data (initial push of a big repository, change with very big file(s)) may require a higher http.postBuffer setting on your git client (not the server). From https://www.kernel.org/pub/software/scm/git/docs/git-config.html

    http.postBuffer

    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.

  • Configuration on your reverse proxy. Usually ngnix the parameter client_max_body_size is a blocker. The reverse proxy may also have a connection timeout that's closing the connection (e.g. TimeOut or ProxyTimeout in apache, proxy_read_timeout in ngnix). Try bypassing the proxy by pushing directly to Bitbucket Server IP:port. If this works, it's highly likely that the proxy server is causing the early disconnect and needs to be tuned.
  • User is using an outbound proxy on his machine that is causing the issue.
  • Using an unsupported GIT version. Make sure the Bitbucket version being used is using a compatible GIT version. More info at Bitbucket Supported Platforms page.

Workaround

  • Push the repository using SSH as this is an error related your HTTP(S) environment / set up.
  • Bypass the proxy. Push directly to Bitbucket Server IP:port.

Resolution

Last modified on Sep 6, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.