How to fix npm ERR! code EAI_NONAME npm ERR! errno EAI_NONAME npm ERR! getaddrinfo EAI_NONAME registry.npmjs.org in npm

npmINTERMEDIATEHIGHUpdated Dec 5, 2025· 239 views

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
  1. Verify network connectivity and DNS resolution
  2. Remove npm proxy configuration
  3. Update DNS nameservers (especially for WSL2/Linux)
  4. Try a different network connection
npm — error
# 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
npm ERR! code EAI_NONAME
npm ERR! errno EAI_NONAME
npm 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

  1. DNS server misconfiguration or unavailability—your system cannot reach functional DNS servers
  2. Proxy settings blocking npm registry access—corporate proxies incorrectly configured or intercepting requests
  3. WSL2/Docker network isolation—containers have broken DNS configuration or cannot reach host DNS
  4. Corporate firewall or DNS filtering—registry.npmjs.org domain is blocked or redirected
  5. Typo in registry URL or custom npm registry configuration pointing to non-existent hostname
  6. 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"

1Verify network connectivity and DNS resolution

First, confirm that your internet connection is working and DNS is resolving hostnames:

bash
# 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

If ping fails or times out, your DNS is not resolving.

2Remove npm proxy configuration

Incorrect proxy settings are a common cause. Clear any proxy configuration from npm:

bash
# 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-proxy

If you need to use a proxy (corporate environment), configure it correctly:

bash
npm config set proxy http://username:password@proxy-host:port
npm config set https-proxy http://username:password@proxy-host:port
3Update DNS nameservers (especially for WSL2/Linux)

If you're on WSL2, Linux, or Docker, update your DNS configuration to use public DNS servers:

bash
# 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.1
4Try a different network connection

Network-specific issues may require switching networks:

bash
# Disconnect from corporate/home network
# Connect to a different network (mobile hotspot, public WiFi, etc.)

# Try npm install on the new network
npm install

If npm install succeeds on a different network, the issue is with your original network's DNS or proxy configuration.

5Restart network services and containers

Network services may have stale state. Restart them:

bash
# 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 up
6Update npm and Node.js, clear cache

Outdated npm versions may have DNS bugs. Update both:

bash
# 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 install

Advanced 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