KhueApps
Home/DevOps/Fixing Git remote end hung up unexpectedly during push

Fixing Git remote end hung up unexpectedly during push

Last updated: October 07, 2025

What this error means

Git prints "The remote end hung up unexpectedly" when the server closes the connection mid-operation (push, fetch, or clone). Common root causes:

  • Network or proxy issues (HTTP/2 quirks, SSL interception, timeouts)
  • Large pushes (huge packfiles, binaries not using LFS)
  • Authentication or credential problems
  • Server-side hooks or quotas rejecting the update

This guide focuses on practical DevOps troubleshooting for pushes.

Quickstart: most common fixes

Try these in order (stop when the push succeeds):

  • Reduce protocol quirks (HTTP remotes):
    • git config --global http.version HTTP/1.1
    • git config --global http.expectContinue false
  • Remove broken proxy settings:
    • git config --global --unset http.proxy
    • unset HTTPS_PROXY https_proxy HTTP_PROXY http_proxy
  • Re-authenticate:
    • For HTTPS: update your credential helper or token
    • For SSH: ssh -T git@your-host and refresh keys/agent
  • Avoid huge packfiles:
    • Commit smaller batches, or use Git LFS for large binaries
  • Gather diagnostics:
    • GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main

Minimal working example (local push)

Use a local bare remote to confirm your client is fine and isolate network/proxy issues.

# Create a demo repo
rm -rf /tmp/git-mwe && mkdir -p /tmp/git-mwe && cd /tmp/git-mwe
git init
printf "hello\n" > readme.txt
git add readme.txt
git commit -m "init"

# Create a local bare remote and push
mkdir -p /tmp/remote.git && cd /tmp/remote.git
git init --bare
cd /tmp/git-mwe
git remote add origin /tmp/remote.git
git branch -M main
git push -u origin main

If this local push works, your Git client and repo are fine. Failures against your real remote likely involve network, proxy, auth, or server policy.

Step-by-step troubleshooting

  1. Verify the remote URL and connectivity
  • git remote -v
  • For HTTPS: git ls-remote <url>
  • For SSH: ssh -T git@host (expect a greeting/permission message)
  1. Enable trace logs to see the failure point
  • GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin main
  • Look for: proxy in use, HTTP/2 frames, TLS errors, 413/50x, or abrupt FIN/RST
  1. Disable HTTP/2 and Expect: 100-continue (HTTPS only)
  • git config --global http.version HTTP/1.1
  • git config --global http.expectContinue false
  1. Fix proxy and SSL interception
  • Unset unintended proxies:
    • git config --global --unset http.proxy
    • unset HTTPS_PROXY https_proxy HTTP_PROXY http_proxy
  • If a corporate proxy is required, set it explicitly and ensure the proxy CA is trusted at the OS level.
  1. Re-authenticate
  • HTTPS: update or recreate your personal access token; ensure your credential helper stores it
    • git config --global credential.helper store|manager|osxkeychain|libsecret
  • SSH: ensure the right key is offered and allowed
    • ssh -vT git@host to debug key selection
  1. Handle large files properly
  • Identify large blobs:
    git rev-list --objects --all \
    | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
    | awk '$1=="blob"{printf "%-8.2f MB  %s\n", $3/1024/1024, $4}' \
    | sort -hr | head -20
    
  • Track binaries with Git LFS (requires LFS installed):
    git lfs install
    git lfs track "*.bin" "*.zip" "*.iso"
    git add .gitattributes
    git commit -m "track large binaries via LFS"
    # Migrate existing history if needed (be cautious on shared repos)
    git lfs migrate import --include="*.bin,*.zip,*.iso"
    
  1. Reduce pack size and memory use
  • Repack locally before pushing:
    • git gc --aggressive --prune=now
  • Limit resources if memory is tight:
    • git config --global pack.threads 1
    • git config --global pack.windowMemory 256m
    • git config --global pack.deltaCacheSize 256m
  1. Push in smaller batches
  • Split large changes across multiple commits/branches
  • Push a single branch first: git push origin main
  • Avoid pushing tags and all branches at once
  1. Increase low-speed thresholds or avoid timeouts
  • git config --global http.lowSpeedLimit 0
  • git config --global http.lowSpeedTime 0
  1. Check server-side causes (DevOps)
  • Verify repository quotas, max upload size, and pre-receive hooks
  • Ensure server has disk space and no reverse proxy/body-size limits
  • Inspect server logs for TLS/proxy resets or hook failures

Common causes and fixes

SymptomLikely causeFix
Error appears after large object countHuge packfileUse LFS, repack, push smaller batches
Works on VPN/off-corp, fails on office networkProxy/SSL interceptionSet/clear proxy, trust CA, force HTTP/1.1
SSH message: connection closedSSH key or server capacityValidate keys, retry, check server load
413/50x in traceReverse proxy/body limitRaise body-size/timeouts, chunk or LFS
Random mid-transfer resetsHTTP/2/proxy bughttp.version HTTP/1.1, expectContinue false

Pitfalls to avoid

  • Blindly increasing http.postBuffer: modern Git rarely needs this; it often masks real issues
  • Disabling SSL verification: insecure; fix trust store instead
  • Rewriting shared history during LFS migration without coordination
  • Pushing everything (all branches/tags) at once when bandwidth is constrained
  • Using --no-verify to bypass client hooks; it will not bypass server-side hooks

Performance notes

  • Prefer SSH or HTTPS close to your infrastructure edge to minimize proxy hops
  • Tune compression for your workload:
    • Faster push: git config --global core.compression 2
    • Smaller pack: core.compression 7–9 (slower CPU)
  • For CI/CD runners, cache and reuse the Git object database between jobs to avoid re-packing
  • Shallow clones reduce fetch size; shallow pushes are limited—unshallow before large pushes
  • On servers, ensure adequate file descriptors, disk I/O, and adjust reverse proxy timeouts to exceed expected push duration

Tiny FAQ

Q: Why did increasing http.postBuffer seem to help once? A: It changed timing, not the root cause. Fix proxy/HTTP/2 issues or use LFS for large files.

Q: Is this error always client-side? A: No. It often indicates the server or an intermediary closed the connection. Check server logs and proxies.

Q: Does Git LFS fix all large push failures? A: It fixes binary transfer size issues, but proxies and server limits still need proper configuration.

Q: Can I switch protocols to work around the issue? A: Yes. If HTTPS fails, try SSH (and vice versa). This often bypasses a problematic proxy or TLS termination layer.

Series: Git

DevOps