npm ENOTFOUND "request to … failed, reason: getaddrinfo ENOTFOUND" - Fix in CI
ENOTFOUND is a DNS failure - Node could not resolve the registry hostname to an IP at all. In CI this is almost always a transient DNS blip, a wrong registry host, or a proxy that blocks name resolution.
What this error means
npm install/npm ci fails before downloading anything with getaddrinfo ENOTFOUND for the registry host. The hostname simply did not resolve, so npm never opened a connection.
npm error code ENOTFOUND
npm error syscall getaddrinfo
npm error errno ENOTFOUND
npm error network request to https://registry.npmjs.org/lodash failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.orgCommon causes
Transient DNS failure on the runner
A momentary DNS outage or a slow resolver on the CI network means the registry hostname does not resolve. A retry on a fresh runner usually succeeds.
A typo or wrong custom registry host
An .npmrc pointing at a misspelled or decommissioned registry hostname produces a permanent ENOTFOUND - the name genuinely does not exist.
A proxy or air-gapped network blocks name resolution
Behind a restrictive proxy, direct DNS to public registries can be blocked; npm must be pointed at an internal mirror whose host the runner can resolve.
How to fix it
Retry and confirm the registry host
Re-run the job, and verify the configured registry resolves from the runner.
npm config get registry
# confirm the host resolves on the runner
node -e "require('dns').lookup('registry.npmjs.org', (e,a)=>console.log(e||a))"
npm ciPoint at a resolvable mirror
- Behind a proxy, set
registryto an internal mirror whose host the runner can resolve. - Raise npm fetch retries so a single DNS blip self-recovers.
- Pre-warm or cache
~/.npmso most installs do not hit the network at all.
How to prevent it
- Use a registry host the CI network can always resolve.
- Raise fetch-retries so transient DNS blips self-heal.
- Cache the npm download cache keyed on the lockfile.