npm ERR! code ENOTFOUND
This error matches known, documented patterns with reliable solutions.
Quick Fix (Most Common Solution)
- Check your internet connection
- Configure proxy settings in .npmrc
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.
What This Error Means
npm cannot connect to the package registry server.
Frequently documented in developer and vendor support forums.
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
- Check your internet connection
- Configure proxy settings in .npmrc
- 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
- Test DNS resolution: nslookup registry.npmjs.org
- Check internet connectivity: ping 8.8.8.8
- Verify the registry URL: npm config get registry
- Check for typos in .npmrc registry URL
- 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?
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
- npm install error
- npm dependency error
- node package manager error
- npm ERR! message
Common Search Variations
- "npm install not working"
- "npm ERR how to fix"
- "node modules error fix"
- "npm install failed what to do"
- "npm dependency conflict solution"
- "why does npm install fail"
Related Errors
Still Stuck?
Paste a different error message or upload a screenshot to get help instantly.