How to fix npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org in npm
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- Check your internet connection and DNS availability
- Clear npm cache and remove proxy configuration
- Configure your system's DNS resolver
- Fix Docker DNS if running npm inside containers
# Test general internet connectivityping google.comping 8.8.8.8# Test DNS resolution for the npm registrynslookup registry.npmjs.orgdig registry.npmjs.orgnpm ERR! code EAI_NODATAnpm ERR! errno EAI_NODATAnpm 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
- 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
- Proxy configuration conflicts—npm proxy settings are incorrect or incompatible with your network
- WSL (Windows Subsystem for Linux) DNS resolution issues—DNS configuration pointing to inaccessible nameservers
- 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"
First verify basic network connectivity is working:
# 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.orgIf ping works but nslookup/dig fails, your DNS resolver is the problem.
Start with a clean slate by clearing npm's cache and removing potentially conflicting proxy settings:
# 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-proxyThen try npm install again.
Change your DNS resolver to a reliable public DNS service:
On Linux (including WSL):
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.1On macOS:
networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4On Windows:
Settings → Network & Internet → Change adapter options → Right-click connection → Properties → IPv4 → Preferred DNS: 8.8.8.8
If getting EAI_NODATA inside Docker, configure DNS in your container:
Method 1: Docker daemon configuration
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 dockerMethod 2: Docker Compose
services:
app:
image: node:18
dns:
- 8.8.8.8
- 8.8.4.4Configure npm to retry failed requests and increase timeout thresholds:
# 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 installIf the primary npm registry has issues, switch to an alternative registry or mirror:
# 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
- 📚npm Official Documentation
- 📖Docs: npm registry config(Official Docs)
- 💬SO: npm registry DNS issues(Stack Overflow)
- 🐙GitHub: npm issues(GitHub)