The EHOSTDOWN error occurs when npm cannot connect to the npm registry or another host due to network issues, firewall blocks, or IPv6 misconfigurations. Fixing it requires checking your network connectivity and registry configuration.
EHOSTDOWN is a network-level error that indicates the npm client was unable to reach the specified host. This typically happens when npm tries to connect to registry.npmjs.org or a custom npm registry, but the connection is blocked or the host is unreachable. The error can stem from several sources: your internet connection may be down, a firewall or corporate proxy may be blocking access, DNS resolution may be failing, or IPv6 routing issues may be preventing the connection. Unlike ECONNREFUSED (which means the server rejected the connection), EHOSTDOWN means the client couldn't even reach the host to attempt a connection.
First, verify that your internet is actually working and the npm registry is online.
# Test basic internet connectivity
ping 8.8.8.8
# Test DNS resolution
ping registry.npmjs.orgIf ping to 8.8.8.8 fails, your internet is down. If ping to registry.npmjs.org fails or shows 'Destination Host Unreachable', you have a firewall or routing issue. Check https://status.npmjs.org for registry outages.
Clear any corrupted cache and review your npm configuration:
npm cache clean --force
npm config ls
npm config get registry
npm config get proxy
npm config get https-proxyVerify the registry is set to https://registry.npmjs.org (or your custom registry). If you see proxy values set, make note of them as they may be causing the issue.
IPv6 misconfigurations are a common cause of EHOSTDOWN errors. Temporarily disable it to test:
On Linux/macOS:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1On Windows (PowerShell as Admin):
Reg add HKLM\SYSTEM\CurrentControlSet\Services\TCPIP6\Parameters /v DisabledComponents /t REG_DWORD /d 0xffAfter disabling IPv6, try npm install again. If it succeeds, you've found the root cause.
If you're behind a corporate firewall or proxy, configure npm to use it:
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
npm installTo reset proxy settings later:
npm config set proxy null
npm config set https-proxy nullYour local and global .npmrc files may have stale or incorrect configuration:
cat ~/.npmrc
cat .npmrc
npm config ls --allLook for any unusual registry URLs, proxy settings, or other network-related config. If you find incorrect entries:
npm config delete registry
npm config delete proxyIf still having issues, try with verbose output:
npm install --verboseEHOSTDOWN is a lower-level socket error that indicates the host is unreachable at the network level, different from ECONNREFUSED (connection rejected) or ENOTFOUND (DNS lookup failed). If IPv6 disabling fixes your issue, consider making it permanent on your system. Some users have reported that connecting to a VPN resolves EHOSTDOWN issues, suggesting the problem may be ISP-level routing or firewall policies. If you're using a corporate network, contact your IT department about proxy requirements or firewall rules blocking port 443 to registry.npmjs.org.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error