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

npmINTERMEDIATEHIGHUpdated Dec 5, 2025· 357 views

EAI_NODATA is a DNS error indicating the DNS server responded but had no records for the hostname. Configure public DNS servers, check proxy settings, or verify network connectivity.

Quick fix

Fixes EAI_NODATA

# Test general internet connectivity
ping google.com
ping 8.8.8.8

# Test DNS resolution for the npm registry
nslookup registry.npmjs.org
dig registry.npmjs.org
  1. Check your internet connection and DNS availability
  2. Clear npm cache and remove proxy configuration
  3. Configure your system's DNS resolver
  4. Fix Docker DNS if running npm inside containers
npm — error
# Test general internet connectivity
ping google.com
ping 8.8.8.8
# Test DNS resolution for the npm registry
nslookup registry.npmjs.org
dig registry.npmjs.org
npm ERR! code EAI_NODATA
npm ERR! errno EAI_NODATA
npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org

What this error means

EAI_NODATA is a DNS resolution error that occurs when the operating system's DNS resolver attempts to look up the npm registry domain but receives a response indicating that no data is available for that domain. Unlike ENOTFOUND (where the DNS server doesn't recognize the domain), EAI_NODATA means the DNS server responded but had no DNS records (A or AAAA) for the requested host. This is a temporary DNS failure that typically indicates network connectivity issues, misconfigured DNS servers, or transient resolution problems.

Typical symptoms

  • npm install, npm ci, or npm update commands fail with 'getaddrinfo EAI_NODATA registry.npmjs.org'
  • You can browse websites normally and ping other hosts, but npm specifically fails to resolve the registry
  • The error occurs intermittently and works after retrying, suggesting temporary DNS issues
  • Inside Docker containers, npm install fails even though the host system has working internet
  • The error message includes 'syscall: getaddrinfo' followed by 'code: EAI_NODATA'

Common causes

  1. DNS server misconfiguration or failure—your system's DNS resolver is not properly configured or unreachable
  2. Corrupted or auto-generated /etc/resolv.conf file pointing to invalid DNS servers
  3. Docker container DNS issues—container DNS settings don't match the host or DNS server is unavailable
  4. Proxy configuration conflicts—npm proxy settings are incorrect or incompatible with your network
  5. WSL (Windows Subsystem for Linux) DNS resolution issues—DNS configuration pointing to inaccessible nameservers
  6. Temporary network issues—brief connectivity loss or DNS server timeout during the lookup request

How to fix "npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org"

1Check your internet connection and DNS availability

First verify basic network connectivity is working:

bash
# Test general internet connectivity
ping google.com
ping 8.8.8.8

# Test DNS resolution for the npm registry
nslookup registry.npmjs.org
dig registry.npmjs.org

If ping works but nslookup/dig fails, your DNS resolver is the problem.

2Clear npm cache and remove proxy configuration

Start with a clean slate by clearing npm's cache and removing potentially conflicting proxy settings:

bash
# Clear npm cache
npm cache clean --force

# Remove proxy settings
npm config rm proxy
npm config rm https-proxy

# Verify no proxy is set
npm config get proxy
npm config get https-proxy

Then try npm install again.

3Configure your system's DNS resolver

Change your DNS resolver to a reliable public DNS service:

On Linux (including WSL):

bash
sudo nano /etc/resolv.conf

# Add or replace with public DNS servers at the top
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1

On macOS:

bash
networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4

On Windows:
Settings → Network & Internet → Change adapter options → Right-click connection → Properties → IPv4 → Preferred DNS: 8.8.8.8

4Fix Docker DNS if running npm inside containers

If getting EAI_NODATA inside Docker, configure DNS in your container:

Method 1: Docker daemon configuration

bash
sudo nano /etc/docker/daemon.json

# Add or update:
{
  "dns": ["8.8.8.8", "8.8.4.4", "1.1.1.1"]
}

# Restart Docker
sudo systemctl restart docker

Method 2: Docker Compose

yaml
services:
  app:
    image: node:18
    dns:
      - 8.8.8.8
      - 8.8.4.4
5Retry npm with extended timeouts and retry policy

Configure npm to retry failed requests and increase timeout thresholds:

bash
# Increase timeout to 60 seconds
npm config set fetch-timeout 60000

# Set retry policy
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 5000
npm config set fetch-retry-maxtimeout 60000

# Now try again
npm install
6Set a specific npm registry mirror as fallback

If the primary npm registry has issues, switch to an alternative registry or mirror:

bash
# Use Taobao mirror (fast in Asia, works globally)
npm config set registry https://registry.npmmirror.com

# Clear cache and retry
npm cache clean --force
npm install

# To revert to default npm registry
npm config set registry https://registry.npmjs.org/

Advanced notes

EAI_NODATA is distinct from similar DNS errors: ENOTFOUND means the domain doesn't exist or DNS server didn't respond, while EAI_AGAIN means a temporary timeout occurred. EAI_NODATA specifically means the DNS server responded but had no records for that host. Docker users should note that Alpine Linux images sometimes have stricter DNS handling—switching to Debian-based images (bookworm-slim, bullseye) may resolve persistent issues without configuration changes.

Frequently asked questions

What does "EAI_NODATA" mean?
EAI_NODATA is a DNS resolution error that occurs when the operating system's DNS resolver attempts to look up the npm registry domain but receives a response indicating that no data is available for that domain. Unlike ENOTFOUND (where the DNS server doesn't recognize the domain), EAI_NODATA means the DNS server responded but had no DNS records (A or AAAA) for the requested host. This is a temporary DNS failure that typically indicates network connectivity issues, misconfigured DNS servers, or transient resolution problems.
How do I fix "EAI_NODATA"?
EAI_NODATA is a DNS error indicating the DNS server responded but had no records for the hostname. Configure public DNS servers, check proxy settings, or verify network connectivity.
What causes "EAI_NODATA"?
DNS server misconfiguration or failure—your system's DNS resolver is not properly configured or unreachable Corrupted or auto-generated /etc/resolv.conf file pointing to invalid DNS servers Docker container DNS issues—container DNS settings don't match the host or DNS server is unavailable
Is the "EAI_NODATA" 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