The ENETUNREACH error means npm cannot reach the network to connect to the registry. This indicates a network routing problem, disconnected network, or firewall blocking outbound connections.
ENETUNREACH stands for "Network Unreachable" and is a low-level network error. It occurs when your system has no route to the destination network where the npm registry resides. This is different from connection refused (server rejects) or timeout (server doesn't respond) - with ENETUNREACH, the packets cannot even leave your network. This typically indicates a fundamental network configuration problem rather than an npm-specific issue.
Verify your network interfaces are up:
# Linux
ip addr
ip link show
# macOS
ifconfig
# Windows
ipconfig /allLook for your active interface (eth0, wlan0, en0).
Check if you can reach external networks:
ping -c 4 8.8.8.8
ping -c 4 google.comIf ping fails, the issue is network-level, not npm.
Verify you have a default route:
# Linux/macOS
ip route # or route -n
netstat -rn
# Windows
route printYou should see a default route (0.0.0.0/0) pointing to your gateway.
Sometimes IPv6 routing fails while IPv4 works:
npm config set prefer-ipv4 true
# or use Node.js flag
NODE_OPTIONS="--dns-result-order=ipv4first" npm installRestart networking to reset connections:
# Linux
sudo systemctl restart NetworkManager
# or
sudo service networking restart
# macOS - toggle Wi-Fi or:
sudo ifconfig en0 down && sudo ifconfig en0 upIf using VPN, ensure it's connected or fully disconnected:
# Check for VPN interfaces
ip addr | grep -E "tun|tap|wg"
# Temporarily disable firewall to test
sudo ufw disable # LinuxRe-enable firewall after testing.
In Docker, ENETUNREACH often indicates the container network is misconfigured. Try --network=host for testing. In Kubernetes, check pod network policies and CNI plugin status. For WSL2, network issues can occur when Windows networking changes - try wsl --shutdown and restart. Some corporate VPNs use split tunneling that may not include npm registry routes.
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