How to fix npm ERR! code EAI_FAIL npm ERR! errno EAI_FAIL npm ERR! request to https://registry.npmjs.org failed, reason: getaddrinfo EAI_FAIL in npm

npmINTERMEDIATEHIGHUpdated Dec 5, 2025· 324 views

EAI_FAIL is a DNS resolution error indicating npm cannot resolve the registry hostname. Check your internet connection, configure DNS servers, or verify proxy settings.

Quick fix

Fixes EAI_FAIL

ping registry.npmjs.org
  1. Check your internet connection and ping the npm registry
  2. Clear npm cache and retry the installation
  3. Remove or verify npm proxy configuration
  4. Change your DNS settings to a public resolver
npm — error
ping registry.npmjs.org
npm ERR! code EAI_FAIL
npm ERR! errno EAI_FAIL
npm ERR! request to https://registry.npmjs.org failed, reason: getaddrinfo EAI_FAIL

What this error means

The EAI_FAIL error indicates a temporary failure in DNS name resolution. When npm tries to install packages, it needs to resolve the hostname of the npm registry (registry.npmjs.org) to an IP address via DNS lookup. If the DNS server cannot resolve the hostname, or the DNS request times out, Node.js returns this error. This is typically a network connectivity issue rather than a problem with npm itself, and the error may be transient—meaning it could succeed on a retry.

Typical symptoms

  • npm install command fails with 'getaddrinfo EAI_FAIL' error message
  • npm ci or npm update commands hang or timeout during package resolution
  • Error occurs at specific point during large dependency installations
  • npm works fine on other networks or computers, but fails on current network
  • Ping to registry.npmjs.org or other hosts fails or times out

Common causes

  1. DNS server misconfiguration or unavailability—the configured DNS server is down, overloaded, or not responding
  2. Corporate network proxy blocking outbound DNS or HTTP requests to the npm registry
  3. Network adapter misconfiguration, outdated drivers, or firewall rules blocking DNS (port 53) or HTTPS (port 443)
  4. Temporary network outage, router reset, or ISP DNS failure
  5. Docker or container DNS resolution failure—container's DNS configuration may be stale or incorrect
  6. ISP or router DNS caching issues—responses cached from previous failed lookups

How to fix "npm ERR! code EAI_FAIL npm ERR! errno EAI_FAIL npm ERR! request to https://registry.npmjs.org failed, reason: getaddrinfo EAI_FAIL"

1Check your internet connection and ping the npm registry

Verify that your network is working and can reach the npm registry:

bash
ping registry.npmjs.org

If ping fails, your network cannot reach external hosts. Check your internet connection, restart your router, and ensure no firewall is blocking outbound traffic.

2Clear npm cache and retry the installation

Sometimes npm cache becomes corrupted or stale. Clear it and retry:

bash
npm cache clean --force
npm install

If the error is transient, the retry should succeed.

3Remove or verify npm proxy configuration

Check if you have proxy settings configured that are causing the issue:

bash
npm config list

Look for 'proxy' and 'https-proxy' entries. If they are set and causing problems, remove them:

bash
npm config rm proxy
npm config rm https-proxy

If you're behind a corporate proxy, configure npm correctly:

bash
npm config set proxy http://[username:password@]proxy.company.com:[port]
npm config set https-proxy http://[username:password@]proxy.company.com:[port]
4Change your DNS settings to a public resolver

If your network's DNS server is misconfigured, switching to a public DNS resolver often fixes the issue.

For Linux/WSL, edit /etc/resolv.conf:

bash
sudo nano /etc/resolv.conf

Add one of these nameservers at the top:

bash
nameserver 1.1.1.1      # Cloudflare
nameserver 8.8.8.8      # Google
nameserver 9.9.9.9      # Quad9

Save and exit. Then retry npm install.

5Restart your machine or network adapter

Network adapters can become stale or misconfigured. A restart often resolves transient DNS issues:

bash
# Linux/WSL: restart networking
sudo systemctl restart networking

# Windows: reset network adapter
ipconfig /release
ipconfig /renew

Then try npm install again.

6Switch networks or contact your network administrator

If all else fails, try connecting to a different network (mobile hotspot, public WiFi) and retry:

bash
npm install

If npm works on a different network, the issue is with your current network configuration. Contact your network administrator to verify DNS is working and registry.npmjs.org is accessible.

Advanced notes

The EAI_FAIL error is fundamentally a DNS resolution failure. Node.js does not perform DNS caching—it delegates all DNS resolution to the operating system, which means the issue is almost always environmental. In Docker, the container's DNS configuration is inherited from the host at startup; if the host's network changes after the container starts, the container may retain stale DNS info. WSL2 users commonly see this error when corporate networks intercept DNS traffic—using public resolvers like Cloudflare (1.1.1.1) or Google (8.8.8.8) bypasses these restrictions.

Frequently asked questions

What does "EAI_FAIL" mean?
The EAI_FAIL error indicates a temporary failure in DNS name resolution. org) to an IP address via DNS lookup. js returns this error.
How do I fix "EAI_FAIL"?
EAI_FAIL is a DNS resolution error indicating npm cannot resolve the registry hostname. Check your internet connection, configure DNS servers, or verify proxy settings.
What causes "EAI_FAIL"?
DNS server misconfiguration or unavailability—the configured DNS server is down, overloaded, or not responding Corporate network proxy blocking outbound DNS or HTTP requests to the npm registry Network adapter misconfiguration, outdated drivers, or firewall rules blocking DNS (port 53) or HTTPS (port 443)
Is the "EAI_FAIL" 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