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
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- Check your internet connection and ping the npm registry
- Clear npm cache and retry the installation
- Remove or verify npm proxy configuration
- Change your DNS settings to a public resolver
ping registry.npmjs.orgnpm ERR! code EAI_FAILnpm ERR! errno EAI_FAILnpm 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
- 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)
- Temporary network outage, router reset, or ISP DNS failure
- Docker or container DNS resolution failure—container's DNS configuration may be stale or incorrect
- 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"
Verify that your network is working and can reach the npm registry:
ping registry.npmjs.orgIf ping fails, your network cannot reach external hosts. Check your internet connection, restart your router, and ensure no firewall is blocking outbound traffic.
Sometimes npm cache becomes corrupted or stale. Clear it and retry:
npm cache clean --force
npm installIf the error is transient, the retry should succeed.
Check if you have proxy settings configured that are causing the issue:
npm config listLook for 'proxy' and 'https-proxy' entries. If they are set and causing problems, remove them:
npm config rm proxy
npm config rm https-proxyIf you're behind a corporate proxy, configure npm correctly:
npm config set proxy http://[username:password@]proxy.company.com:[port]
npm config set https-proxy http://[username:password@]proxy.company.com:[port]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:
sudo nano /etc/resolv.confAdd one of these nameservers at the top:
nameserver 1.1.1.1 # Cloudflare
nameserver 8.8.8.8 # Google
nameserver 9.9.9.9 # Quad9Save and exit. Then retry npm install.
Network adapters can become stale or misconfigured. A restart often resolves transient DNS issues:
# Linux/WSL: restart networking
sudo systemctl restart networking
# Windows: reset network adapter
ipconfig /release
ipconfig /renewThen try npm install again.
If all else fails, try connecting to a different network (mobile hotspot, public WiFi) and retry:
npm installIf 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
- 📚npm Official Documentation
- 📖Docs: EAI_FAIL Error(Official Docs)
- 💬SO: npm EAI_FAIL network errors(Stack Overflow)
- 🐙GitHub: npm repository(GitHub)