Skip to content
Latchkey

npm ETIMEDOUT "network request … failed, reason: connect ETIMEDOUT" - Fix in CI

ETIMEDOUT means npm opened (or tried to open) a connection to the registry and it never completed in time. DNS resolved fine, but the TCP connection or the download stalled.

What this error means

npm install/npm ci hangs while fetching, then fails with connect ETIMEDOUT or a request timeout for the registry. Re-running the job usually succeeds, the hallmark of a transient network stall.

npm output
npm error code ETIMEDOUT
npm error syscall connect
npm error errno ETIMEDOUT
npm error network request to https://registry.npmjs.org/... failed,
reason: connect ETIMEDOUT 104.16.0.35:443

Common causes

Transient network congestion or a slow registry

A congested runner network or an overloaded registry/mirror means the connection cannot complete inside npm’s timeout window.

A proxy silently dropping connections

An egress proxy that blocks or throttles the registry can leave connections hanging until they time out rather than refusing them outright.

How to fix it

Raise the timeout and retries

Give npm more time and more attempts so a single stall self-recovers.

Terminal
npm config set fetch-retries 5
npm config set fetch-retry-maxtimeout 120000
npm config set fetch-timeout 120000
npm ci

Reduce dependence on the slow path

  1. Cache ~/.npm so most packages are already local.
  2. Point at a closer or internal mirror for high-volume pipelines.
  3. Confirm the proxy allows and does not throttle the registry host.

How to prevent it

  • Set generous fetch-timeout and fetch-retries in CI.
  • Cache the npm download cache keyed on the lockfile.
  • Use a nearby mirror to cut connection latency.

Related guides

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