AI Diagnostic Summary

npm ERR! code ENETUNREACH

Well-Documented Error

This error matches known, documented patterns with reliable solutions.

Quick Fix (Most Common Solution)

Seeing "npm ERR! code ENETUNREACH"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.

High confidence
What This Error Means

Your network cannot route to npm servers.

Frequently documented in developer and vendor support forums.

Based on documented solutions and common real-world fixes.
Not affiliated with browser, OS, or device manufacturers.

New here? Learn why exact error messages matter →

Common Causes
  • No internet connection
  • VPN blocking
  • Network misconfiguration
How to Fix
  1. Check internet connection
  2. Disable VPN temporarily
  3. Try different network

Last reviewed: March 2026 How we review solutions

Why This Happens

ENETUNREACH is a system-level network error meaning "network unreachable"—the operating system cannot find a route to the destination IP address. When npm reports this, it means the machine literally cannot establish a TCP connection to the registry server. This is different from ENOTFOUND (DNS failure) or ETIMEDOUT (connection timeout): ENETUNREACH means the kernel's routing table has no path to the target network. The most common cause is a complete lack of internet connectivity—Wi-Fi disconnected, Ethernet unplugged, or VPN not connected when the registry is only accessible through VPN. In corporate environments, this often indicates that the VPN tunnel dropped mid-install or that the network configuration changed. Docker containers that use custom bridge networks may encounter ENETUNREACH if the container's network is not properly connected to the host's internet gateway. IPv6 misconfigurations are another common source: if the DNS resolver returns an IPv6 address for the registry but your network does not support IPv6 routing, the connection attempt fails with ENETUNREACH before falling back to IPv4. Cloud environments (AWS, GCP, Azure) can produce this error when security group rules, NACLs, or route tables block outbound traffic to the registry's IP range.

Quick Diagnostic Checklist
  1. Test basic connectivity: ping 8.8.8.8 or ping google.com
  2. Check if VPN is connected (if the registry requires VPN)
  3. Verify DNS resolution: nslookup registry.npmjs.org
  4. Check your network interface is up: ip addr show (Linux) or ifconfig (macOS)
  5. For Docker: verify the container has network access: docker exec ping 8.8.8.8
Diagnosing ENETUNREACH network connectivity
# Error output:
# npm ERR! code ENETUNREACH
# npm ERR! errno ENETUNREACH
# npm ERR! request to https://registry.npmjs.org/express failed,
# npm ERR! reason: connect ENETUNREACH 104.16.23.35:443
#                                      ^^^^^^^^^^^^^^^ Registry IP

# Step 1: Check basic internet connectivity
$ ping -c 3 8.8.8.8
# ping: connect: Network is unreachable  <-- No internet!

# Step 2: Check network interface
$ ip addr show | grep "state UP"
# (no output)  <-- No active network interface!

# Step 3: Reconnect to network
# For Wi-Fi: nmcli device wifi connect "YourNetwork" password "pass"
# For VPN: sudo openvpn --config your-vpn.ovpn

# Step 4: If connected but still failing, check routes
$ ip route show default
# default via 192.168.1.1 dev eth0  <-- Route exists

# Step 5: IPv6 issue — force IPv4
$ npm config set prefer-ipv4 true
$ npm install   # Bypasses IPv6 routing issues

# Step 6: For Docker containers
$ docker run --network=host node:18 npm install
# Uses host networking to bypass container network issues
Edge Cases & Unusual Scenarios

IPv6-only DNS response with no IPv6 route

Some DNS resolvers return AAAA (IPv6) records before A (IPv4) records. If your network has no IPv6 connectivity, the first connection attempt fails with ENETUNREACH. Set npm to prefer IPv4: npm config set prefer-ipv4 true.

AWS EC2 in private subnet without NAT Gateway

EC2 instances in a private VPC subnet have no direct internet access. npm install fails because there is no route to the npm registry. Set up a NAT Gateway in the public subnet and update the private subnet route table.

Docker build with no network access

Docker BuildKit may disable network access during certain build stages. Ensure your Dockerfile runs npm install in a stage with network access, or use --network=host during the build: docker build --network=host .

Optional follow-up

Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.

Was this explanation helpful?

Explanations are based on documented fixes, real-world reports, and common system behavior. GetErrorHelp is independent and not affiliated with software vendors, device manufacturers, or service providers.
Frequently Asked Questions

How to test connectivity?

Try ping registry.npmjs.org.

Can I work offline?

Use npm pack for offline installs.

What is the difference between ENETUNREACH and ENOTFOUND?

ENOTFOUND means DNS could not resolve the hostname to an IP address. ENETUNREACH means DNS succeeded but the OS has no network route to reach that IP. ENOTFOUND is a name resolution problem; ENETUNREACH is a routing or connectivity problem.

Can a firewall cause ENETUNREACH?

Firewalls typically cause ETIMEDOUT (packets dropped) or ECONNREFUSED (packets rejected), not ENETUNREACH. ENETUNREACH specifically means the OS routing table has no path to the target network—it is almost always a local network configuration issue.

How do I use npm offline?

If you have a populated npm cache from a previous install, npm install will use cached packages. You can also use npm pack to create tarballs of packages and install them locally: npm install ./package-1.0.0.tgz.

Related Resources

Also Known As

Common Search Variations

Related Errors
Still Stuck?

Paste a different error message or upload a screenshot to get help instantly.

Solutions are based on commonly documented fixes and may not apply in all situations.