Git

Git "RPC Failed; curl 56 Recv Failure: Connection Reset by Peer" on Large Push

This error during a large push almost always means the connection was interrupted partway through transferring a large amount of data — commonly due to an HTTP buffer size limitation, a network intermediary dropping the connection, or a server-side timeout for unusually large pushes.

The Problem

Pushing a large amount of data — a big initial commit, a large binary file, an extensive history import — fails partway through:

error: RPC failed; curl 56 Recv failure: Connection reset by peer
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

Smaller pushes work fine, pointing specifically at the data size or transfer duration as the relevant factor rather than a general connectivity problem.

Why It Happens

A handful of distinct causes commonly produce this specific error for large pushes over HTTP(S):

  • Git's HTTP post buffer size is too small for the data being transferred, causing issues specifically with how large pushes are chunked and sent
  • A network intermediary (a corporate proxy, a firewall, certain routers) enforces its own connection timeout or data size limit, terminating the connection before the transfer can complete, independent of anything Git or the Git server itself is doing
  • The Git server itself (especially if self-hosted, or on certain hosting plans with resource limits) has a timeout or size restriction on incoming pushes
  • An unstable or slow network connection simply taking too long to complete the transfer, increasing the chance of an interruption occurring somewhere during the extended transfer window

The Fix

First, increase Git's HTTP post buffer size, which is a very common and often immediately effective fix for exactly this error:

git config --global http.postBuffer 524288000

This sets the buffer to roughly 500MB (specified in bytes), giving Git considerably more room to handle large pushes over HTTP before running into the default, much smaller buffer size that can contribute to this exact failure.

If you're pushing over HTTPS and continue to have issues, consider switching to SSH instead, which handles large transfers differently and often avoids this specific class of HTTP-related error entirely:

git remote set-url origin git@github.com:username/repo.git

Confirm SSH access is properly configured (an SSH key added to your account with the Git hosting provider) before switching, then attempt the push again using this new SSH-based remote URL instead of the previous HTTPS one.

If the issue persists specifically on a corporate or restrictive network, test the same push from a different network (a home connection, a mobile hotspot) to determine whether a network-level intermediary specific to the restrictive network is the actual cause, rather than anything about the push itself or your Git configuration:

# If the push succeeds on a different network, the original network's
# proxy/firewall configuration is confirmed as the actual root cause

For an unusually large single push (a huge initial commit, or a large binary file accidentally committed), consider whether splitting it into multiple, smaller commits and pushing incrementally is more reliable than one enormous atomic push, particularly over an unreliable connection where a smaller transfer window reduces the chance of interruption:

# Push in smaller increments rather than one massive push
git push origin HEAD~10:refs/heads/main  # push up to 10 commits back first
git push origin main  # then push the remainder

If large binary files are a recurring issue, consider whether Git LFS (Large File Storage) is a better fit for your workflow than committing large binaries directly into normal Git history, since Git LFS is specifically designed to handle large file transfers more efficiently and reliably than standard Git object transfer.

Still Not Working?

If increasing the buffer size and switching to SSH both fail to resolve the issue, check the specific error more carefully for HTTP status codes or additional detail that might point at a server-side limit rather than a client-side or network configuration issue — some Git hosting providers (particularly on lower-tier or free hosting plans) enforce explicit repository or single-push size limits, in which case no client-side configuration change resolves the issue, and the actual fix requires either upgrading your hosting plan, splitting the repository, or removing large files from history entirely to bring the push size under the provider's specific limit.