How to fix npm ERR! code EAI_NONAME npm ERR! errno EAI_NONAME npm ERR! getaddrinfo EAI_NONAME registry.npmjs.org in npm
EAI_NONAME is a DNS error indicating the hostname could not be found. Check your internet connection, verify DNS configuration, and remove incorrect proxy settings.
Quick fix
Fixes EAI_NONAME
# Check if you can reach the npm registry
ping registry.npmjs.org
# On Windows, flush DNS cache
ipconfig /flushdns
# On macOS/Linux
sudo dscacheutil -flushcache # macOS
sudo systemctl restart systemd-resolved # Linux- Verify network connectivity and DNS resolution
- Remove npm proxy configuration
- Update DNS nameservers (especially for WSL2/Linux)
- Try a different network connection
# Check if you can reach the npm registryping registry.npmjs.org# On Windows, flush DNS cacheipconfig /flushdns# On macOS/Linuxsudo dscacheutil -flushcache # macOSsudo systemctl restart systemd-resolved # Linuxnpm ERR! code EAI_NONAMEnpm ERR! errno EAI_NONAMEnpm ERR! getaddrinfo EAI_NONAME registry.npmjs.org
What this error means
EAI_NONAME is a DNS (Domain Name System) resolution error that occurs when npm cannot translate a hostname into an IP address. The error indicates that the requested hostname is invalid, no longer exists, or cannot be resolved by your system's DNS server. When you run `npm install`, npm attempts to fetch packages from registry.npmjs.org and other dependencies, but if DNS resolution fails at any point, this error is thrown. This is distinct from temporary network failures (EAI_AGAIN) but indicates a more fundamental hostname lookup problem.
Typical symptoms
- npm install command fails with 'code EAI_NONAME' message
- Error displays 'getaddrinfo EAI_NONAME' followed by a hostname like 'registry.npmjs.org'
- Installing packages works on one network (like mobile hotspot) but fails on another (corporate/home network)
- npm ci and npm install both fail while other applications can access the internet normally
- Error occurs inconsistently, sometimes working and sometimes failing without code changes
Common causes
- DNS server misconfiguration or unavailability—your system cannot reach functional DNS servers
- Proxy settings blocking npm registry access—corporate proxies incorrectly configured or intercepting requests
- WSL2/Docker network isolation—containers have broken DNS configuration or cannot reach host DNS
- Corporate firewall or DNS filtering—registry.npmjs.org domain is blocked or redirected
- Typo in registry URL or custom npm registry configuration pointing to non-existent hostname
- Network adapter issues or stale DNS cache—system cached invalid DNS information
How to fix "npm ERR! code EAI_NONAME npm ERR! errno EAI_NONAME npm ERR! getaddrinfo EAI_NONAME registry.npmjs.org"
First, confirm that your internet connection is working and DNS is resolving hostnames:
# Check if you can reach the npm registry
ping registry.npmjs.org
# On Windows, flush DNS cache
ipconfig /flushdns
# On macOS/Linux
sudo dscacheutil -flushcache # macOS
sudo systemctl restart systemd-resolved # LinuxIf ping fails or times out, your DNS is not resolving.
Incorrect proxy settings are a common cause. Clear any proxy configuration from npm:
# Remove HTTP proxy
npm config rm proxy
# Remove HTTPS proxy
npm config rm https-proxy
# Verify proxy settings are cleared
npm config get proxy
npm config get https-proxyIf you need to use a proxy (corporate environment), configure it correctly:
npm config set proxy http://username:password@proxy-host:port
npm config set https-proxy http://username:password@proxy-host:portIf you're on WSL2, Linux, or Docker, update your DNS configuration to use public DNS servers:
# Edit /etc/resolv.conf
sudo nano /etc/resolv.conf
# Add or replace nameserver entries with:
nameserver 8.8.8.8
nameserver 8.8.4.4
# Or Cloudflare DNS:
nameserver 1.1.1.1
nameserver 1.0.0.1Network-specific issues may require switching networks:
# Disconnect from corporate/home network
# Connect to a different network (mobile hotspot, public WiFi, etc.)
# Try npm install on the new network
npm installIf npm install succeeds on a different network, the issue is with your original network's DNS or proxy configuration.
Network services may have stale state. Restart them:
# Windows - restart network adapter through troubleshooter
# Open Settings > Network & Internet > Status > Network troubleshooter
# macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Linux
sudo systemctl restart systemd-resolved
# Docker
docker-compose down
docker-compose upOutdated npm versions may have DNS bugs. Update both:
# Update npm globally
npm install -g npm@latest
# Check versions
node --version
npm --version
# Clear npm cache
npm cache clean --force
# Clear npm package-lock to force fresh resolution
rm package-lock.json
# Try install again
npm installAdvanced notes
EAI_NONAME differs from EAI_AGAIN (temporary failure)—it's a permanent hostname lookup failure. In corporate environments, internal DNS servers may not be reachable from Docker/WSL containers by default. Corporate proxies sometimes intercept and filter npm registry requests even when proxy settings appear correct. For CI/CD pipelines, ensure the runner's network configuration allows egress to registry.npmjs.org:443. For persistent WSL2 issues, check both wsl.conf and .wslconfig for DNS options—they differ based on your WSL version.
Frequently asked questions
- What does "EAI_NONAME" mean?
- EAI_NONAME is a DNS (Domain Name System) resolution error that occurs when npm cannot translate a hostname into an IP address. The error indicates that the requested hostname is invalid, no longer exists, or cannot be resolved by your system's DNS server. org and other dependencies, but if DNS resolution fails at any point, this error is thrown.
- How do I fix "EAI_NONAME"?
- EAI_NONAME is a DNS error indicating the hostname could not be found. Check your internet connection, verify DNS configuration, and remove incorrect proxy settings.
- What causes "EAI_NONAME"?
- DNS server misconfiguration or unavailability—your system cannot reach functional DNS servers Proxy settings blocking npm registry access—corporate proxies incorrectly configured or intercepting requests WSL2/Docker network isolation—containers have broken DNS configuration or cannot reach host DNS
- Is the "EAI_NONAME" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖Docs: EAI_NONAME Error(Official Docs)
- 💬SO: npm EAI_NONAME DNS errors(Stack Overflow)
- 🐙GitHub: npm repository(GitHub)