Skip to content
Latchkey

"ECONNRESET" mid-download in CI

A connection that was already established got a TCP RST partway through the transfer. Something in the path (the server, a proxy, or a firewall) tore down the socket, so the download aborted before completing.

What this error means

A fetch, npm install, or download fails with "read ECONNRESET", "socket hang up", or "Connection reset by peer" after some bytes have already transferred.

Terminal
npm error code ECONNRESET
npm error network request to https://registry.npmjs.org/... failed, reason:
read ECONNRESET

Common causes

A proxy or firewall drops long-lived connections

An intermediary with an idle or duration limit sends a reset mid-transfer, especially for large artifacts over a slow link.

The server closed the connection abruptly

A registry or mirror under load, or a keep-alive reuse race, can reset an in-flight connection.

How to fix it

Retry with backoff

Resets mid-download are usually transient; retry the fetch a few times so a clean attempt can complete.

Terminal
for i in 1 2 3; do curl -fSL "$URL" -o out.tgz && break; sleep 5; done

Reduce connection reuse that triggers resets

For clients that reuse sockets aggressively, lowering concurrency or disabling keep-alive reuse can avoid the reset path.

Terminal
npm config set maxsockets 1
npm config set fetch-retries 5

How to prevent it

  • Cache large artifacts so a single reset does not force a full refetch.
  • Keep transfers under any proxy idle or duration limits, or raise those limits.
  • Add retries around downloads so a mid-transfer reset self-heals.

Related guides

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