BugMedic

npm ERR! code EAI_AGAIN: reach the registry before fixing packages

Confirm the registry hostname resolves, then fix proxy or network configuration.

By BugMedic editorial teamLast source review: 2026-09-27Windows, macOS, Linux

npm cannot reach the registry because the hostname does not resolve. Verify DNS for the configured registry, check proxy and VPN settings, and retry before changing dependencies.

Try these fixes in order

01

Confirm which registry hostname fails

Run npm config get registry to see the exact hostname npm uses, then test it with nslookup. If the name does not resolve, the problem is DNS, not your package.json.

npm config get registry
nslookup registry.npmjs.org
02

Separate a registry outage from local DNS

Check the registry's status page and test general connectivity. If only the registry fails while other hosts resolve, wait or check status; if nothing resolves, fix local DNS first.

03

Configure the proxy npm should use

If the network requires a proxy, set it with npm config set proxy and https-proxy to match the working browser configuration. Remove stale proxy entries when leaving the corporate network.

npm config set proxy <proxy-url>
npm config set https-proxy <proxy-url>
04

Retry and read the next error fresh

Retry the original npm install. If EAI_AGAIN is gone but a new error appears, such as EACCES or a 404, diagnose that message on its own terms instead of continuing network fixes.

Interpret what you see

Every install fails with EAI_AGAIN, even for well-known packages

What it suggests: npm could not resolve the registry hostname at all, so no package metadata could be fetched; this is environmental, not a dependency problem.

Next check: Run npm config get registry, then resolve that hostname with nslookup to separate DNS failure from registry outage.

The browser reaches the registry site but npm cannot

What it suggests: DNS works but npm's traffic must pass through a proxy that is missing or wrong in npm's config.

Next check: Check npm config get proxy https-proxy against the browser's working proxy settings or IT documentation.

The failure is intermittent rather than constant

What it suggests: The public registry is reachable but slow or briefly failing, which can surface as transient network errors rather than steady EAI_AGAIN.

Next check: Check the registry status page and retry; a steady EAI_AGAIN across hosts still points at local DNS.

Why this happens

  • DNS cannot resolve the registry hostname on this machine or network.
  • A required corporate proxy or VPN is not configured for npm, or a captive portal is intercepting traffic.

Still not working?

Pointing npm at an unofficial mirror to dodge a DNS problem trades a network issue for a supply-chain risk. Fix name resolution or proxy configuration first, and only use a registry your organization operates or explicitly trusts.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related npm / Node.js guides