Skip to content
Latchkey

Git "fatal: the remote end hung up unexpectedly" in CI

The remote closed the connection before the transfer finished. On a large push or clone this is usually a buffer or timeout cutting off the stream, not a problem with the repository itself.

What this error means

A clone, fetch, or (most often) a git push of many/large objects fails with fatal: the remote end hung up unexpectedly, sometimes after "Writing objects" reaches 100%. Smaller pushes succeed; the big one drops.

git push output
Writing objects: 100% (1242/1242), 312.40 MiB | 4.21 MiB/s, done.
fatal: the remote end hung up unexpectedly
fatal: sha1 file '<stdout>' write error: Broken pipe

Common causes

A large transfer exceeding a proxy/server limit

A big push or clone over HTTPS can exceed a proxy body-size limit or idle timeout, so the far end closes the connection mid-stream.

Transient network drop

A brief connectivity blip aborts the in-flight transfer. Nothing is wrong with the repo - a retry often completes.

How to fix it

Raise the HTTP post buffer

A larger buffer lets Git send bigger chunks before flushing, which avoids tripping small proxy limits on a large push.

Terminal
git config --global http.postBuffer 524288000   # 500 MB

Shrink the transfer or push in batches

  1. Clone shallow (--depth 1) so a fetch moves far less data.
  2. For a huge first push, push in smaller commit ranges rather than one giant pack.
  3. Switch to the SSH remote if HTTPS proxies keep truncating the transfer.

Retry the transient drop

If the disconnect is intermittent, a bounded retry around the operation usually succeeds on the next attempt.

Terminal
for i in 1 2 3; do
  git push origin main && break
  echo "push failed (attempt $i), retrying..."; sleep 5
done

How to prevent it

  • Raise http.postBuffer on runners that push large packs through a proxy.
  • Use shallow clones in CI to keep transfers small.
  • Prefer SSH for large pushes behind body-size-limited HTTPS proxies.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →