AI Diagnostic Summary

npm ERR! code ENOTFOUND

Well-Documented Error

This error matches known, documented patterns with reliable solutions.

Quick Fix (Most Common Solution)

Seeing "npm ERR! code ENOTFOUND"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.

High confidence
What This Error Means

npm cannot connect to the package registry server.

Frequently documented in developer and vendor support forums.

Based on documented solutions and common real-world fixes.
Not affiliated with browser, OS, or device manufacturers.

New here? Learn why exact error messages matter →

Common Causes
  • No internet connection
  • Corporate firewall blocking npm
  • npm registry is down
How to Fix
  1. Check your internet connection
  2. Configure proxy settings in .npmrc
  3. Use a different registry mirror

Last reviewed: March 2026 How we review solutions

Why This Happens

ENOTFOUND is a DNS resolution error—the system's DNS resolver could not translate the registry hostname (typically registry.npmjs.org) into an IP address. This is fundamentally a network infrastructure problem, not an npm problem. The most common cause is a lack of internet connectivity: Wi-Fi disconnected, Ethernet cable unplugged, or a VPN that routes DNS queries through a tunnel that is not connected. Corporate DNS servers are the second most frequent source—they may block resolution of external domains, return incorrect results for internal overrides, or simply be unreachable when the corporate network has an outage. The .npmrc file can also point npm at a custom registry hostname that does not exist or is misspelled. Docker containers sometimes encounter ENOTFOUND when the container's DNS configuration does not match the host's—Alpine-based containers use musl's DNS resolver, which behaves differently from glibc and can fail to resolve hostnames that work on the host system. Temporary DNS outages at the registry provider can also cause this error, though this is rare for npmjs.org which uses Cloudflare's global DNS infrastructure.

Quick Diagnostic Checklist
  1. Test DNS resolution: nslookup registry.npmjs.org
  2. Check internet connectivity: ping 8.8.8.8
  3. Verify the registry URL: npm config get registry
  4. Check for typos in .npmrc registry URL
  5. Try a different DNS server: nslookup registry.npmjs.org 8.8.8.8
Diagnosing and fixing ENOTFOUND DNS errors
# Error output:
# npm ERR! code ENOTFOUND
# npm ERR! errno ENOTFOUND
# npm ERR! request to https://registry.npmjs.org/express failed,
# npm ERR! reason: getaddrinfo ENOTFOUND registry.npmjs.org

# Step 1: Check DNS resolution
$ nslookup registry.npmjs.org
# ** server can't find registry.npmjs.org: SERVFAIL  <-- DNS broken

# Step 2: Try Google's public DNS
$ nslookup registry.npmjs.org 8.8.8.8
# Name: registry.npmjs.org
# Address: 104.16.23.35    <-- Works with different DNS

# Step 3: Fix DNS configuration
# Temporarily (Linux):
$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

# Step 4: Check if .npmrc has a wrong registry
$ npm config get registry
# https://registrey.npmjs.org/   <-- Typo! Extra 'e'
$ npm config set registry https://registry.npmjs.org/

# Step 5: For Docker Alpine containers
# Add to Dockerfile:
# RUN echo "nameserver 8.8.8.8" >> /etc/resolv.conf
# Or use: docker run --dns=8.8.8.8 node:18-alpine npm install
Edge Cases & Unusual Scenarios

Alpine Linux musl DNS resolver limitations

Alpine Linux uses musl libc, whose DNS resolver does not support the search or ndots options in /etc/resolv.conf. This can cause resolution failures in Kubernetes pods where these options are critical. Use the node:18-slim image (Debian-based, uses glibc) instead of node:18-alpine if DNS issues persist.

Corporate split-horizon DNS

Some corporate networks use split-horizon DNS where internal and external names resolve to different addresses depending on whether you are on VPN. If the VPN client misconfigures DNS, external names like registry.npmjs.org may fail to resolve. Disconnect and reconnect the VPN, or add the registry IP to /etc/hosts as a workaround.

DNS cache with stale entry

The local DNS cache may hold a stale or incorrect entry for the registry hostname. Flush the DNS cache: sudo systemd-resolve --flush-caches (Linux), sudo dscacheutil -flushcache (macOS), or ipconfig /flushdns (Windows).

Optional follow-up

Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.

Was this explanation helpful?

Explanations are based on documented fixes, real-world reports, and common system behavior. GetErrorHelp is independent and not affiliated with software vendors, device manufacturers, or service providers.
Frequently Asked Questions

How do I set up a proxy?

Run npm config set proxy http://proxy:port and https-proxy.

Is there an npm status page?

Yes, check status.npmjs.org for registry status.

What is the difference between ENOTFOUND and ENETUNREACH?

ENOTFOUND means DNS could not translate the hostname to an IP address. ENETUNREACH means DNS succeeded but the network has no route to reach that IP. ENOTFOUND is a DNS problem; ENETUNREACH is a routing problem.

Can I install npm packages without DNS?

If you have packages in the npm cache from previous installs, npm install may succeed using cached data. You can also install from local tarballs: npm install ./package-1.0.0.tgz, or run a local registry like Verdaccio.

Why does ENOTFOUND happen intermittently?

Intermittent ENOTFOUND usually points to an unreliable DNS server. Your ISP DNS may have brief outages. Switch to a more reliable DNS provider like Google (8.8.8.8) or Cloudflare (1.1.1.1) by updating your system DNS settings.

Related Resources

Also Known As

Common Search Variations

Related Errors
Still Stuck?

Paste a different error message or upload a screenshot to get help instantly.

Solutions are based on commonly documented fixes and may not apply in all situations.