Skip to content
Latchkey

npm "could not resolve host registry.npmjs.org" in CI - Fix DNS Failures

A could-not-resolve-host error means DNS could not turn the registry hostname into an address. It can be a transient DNS blip or a misconfigured registry URL or proxy.

What this error means

npm install fails with getaddrinfo ENOTFOUND or EAI_AGAIN for registry.npmjs.org or your private registry host. A transient blip clears on retry; a persistent failure points at config.

npm
npm ERR! code ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/react failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.org

Common causes

Transient DNS resolution failure

A momentary DNS outage on the runner fails to resolve the host and clears on retry.

A wrong registry URL or missing proxy

A typo in the registry hostname or a network that requires a proxy makes the name unresolvable persistently.

How to fix it

Verify the registry and DNS

  1. Print the configured registry and confirm the hostname is correct.
  2. Test DNS resolution from the runner.
Terminal
npm config get registry
getent hosts registry.npmjs.org || nslookup registry.npmjs.org

Configure the proxy if required

  1. Set the HTTP/HTTPS proxy npm should use on a restricted network.
  2. Re-run the install.
Terminal
npm config set proxy http://proxy.internal:8080
npm config set https-proxy http://proxy.internal:8080

How to prevent it

  • Pin a correct registry URL, configure any required proxy in the runner image, and add fetch retries. Latchkey managed runners auto-retry transient DNS blips and cache the registry, so intermittent resolution failures usually self-clear.

Related guides

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