[Git] Error: RPC failed; curl 56 Recv failure — Connection reset by peer — How to Fix It
Summary
The Git error error: RPC failed; curl 56 Recv failure: Connection reset by peer occurs when the connection between your system and the remote server is interrupted mid-transfer. This is most common during large pushes, network instability, or when pushing files beyond host limits. The fix involves increasing Git’s HTTP buffer, improving compression, ensuring network stability, and using Git LFS for large files.
Context
Git communicates with remote servers (like GitHub, GitLab, or Bitbucket) over HTTPS or SSH. During large pushes or fetches, Git sends data in compressed chunks using RPC (Remote Procedure Calls). If the network drops, the server times out, or the transfer exceeds configured limits, Git terminates the session with a “curl 56” error — indicating a connection reset. This issue is frequent in large repositories, poor Wi-Fi conditions, VPN environments, or outdated Git versions. It can also appear in CI/CD pipelines or behind proxies that interrupt long HTTP sessions.
Probable Cause
- Unstable network connection or VPN interruptions during push/fetch.
- Large repository or oversized binary files exceeding default transfer limits.
- Server timeout or rate limiting due to prolonged upload sessions.
- Small HTTP buffer defaults in older Git versions.
- Proxy or HTTP/2 connection resets mid-transfer.
Quick Fix
Apply the following fixes to stabilize and optimize Git data transfers:
- Check your network connection — prefer wired over Wi-Fi, disable unstable VPNs.
- Increase Git’s buffer and compression limits:
git config --global http.postBuffer 524288000 # 500 MB
git config --global http.maxRequests 100
git config --global core.compression 9
- Test the connection again by retrying the push:
git push origin main
- If the repository contains very large files, set up Git LFS:
git lfs install
git lfs track "*.zip"
git add .gitattributes
git add
git commit -m "Track large files with Git LFS"
git push origin main
- To clean large files from history, use
git filter-repo:
git filter-repo --strip-blobs-bigger-than 100M
- As a diagnostic test only (not a permanent fix), disable SSL verification:
git config --global http.sslVerify false
# After testing, re-enable it:
git config --global http.sslVerify true
- If issues persist, switch from HTTPS to SSH for better stability:
git remote set-url origin git@github.com:username/repo.git
git push origin main
Full Example
A developer attempts to push a large project to GitHub and sees:
error: RPC failed; curl 56 Recv failure: Connection reset by peer
fatal: the remote end hung up unexpectedly
They increase the buffer size and compression level:
git config --global http.postBuffer 524288000
git config --global core.compression 9
The push now progresses further, but still fails due to 200 MB video files. They enable Git LFS and retry:
git lfs install
git lfs track "*.mp4"
git add .gitattributes
git commit -m "Move large files to LFS"
git push origin main
The upload completes successfully without connection resets.
Pitfalls & Debug
- Symptom: “RPC failed; curl 56” → Fix: Increase
http.postBufferand retry push. - Symptom: Works with small repos only → Fix: Use Git LFS for large binaries.
- Symptom: Error reappears in CI → Fix: Extend pipeline timeout and add retry logic.
- Symptom: HTTPS push unstable → Fix: Switch to SSH for more reliable connections.
- Symptom: SSL-related failures → Fix: Temporarily disable SSL verification only for testing.
Validation & Next Steps
Verify the applied configuration:
git config --list | grep postBuffer
git fsck
Test by pushing smaller commits first to isolate size-related problems. For persistent errors, ensure Git is updated to the latest version and consider splitting large repositories into smaller modules or components for stability.
Sources
Git documentation — git-push
GitHub Docs — Dealing with “RPC failed” errors and large files
Stack Overflow — “curl 56 Recv failure” troubleshooting threads
Atlassian tutorials — Network optimization and Git LFS usage