Fixing npm ERR! code ENOTFOUND: When Your Terminal Can't Find the Registry

beginner๐Ÿ’š Node.js2026-05-02| Node.js (all versions), npm (all versions), Windows, macOS, Linux

Error Message

npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org/package-name failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
#npm#registry#network#proxy#enotfound#dns

Why is npm throwing ENOTFOUND?

Seeing the npm ERR! code ENOTFOUND error usually means your computer and the npm registry have stopped talking to each other. Specifically, the system's DNS lookup failed. It is the technical equivalent of your browser saying "Server Not Found," but happening inside your command line.

In plain English, your computer is shouting, "Where is registry.npmjs.org?" into the void, and getting no response. This usually stems from a dropped Wi-Fi connection, a stale DNS cache, or a corporate firewall blocking your path.

The Wall of Error Text

You are likely staring at a terminal output that looks like this:

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/package-name failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org

How to Fix It

1. The 10-Second Connectivity Check

Start with the basics. Run a quick ping to see if you can reach the outside world at all:

ping registry.npmjs.org

A healthy connection should return replies in under 100ms. If you see "Ping request could not find host," your internet is likely down or your router is misbehaving.

2. Flush Your DNS Cache

DNS issues are surprisingly common. Sometimes your computer remembers an old, broken path to the registry. Flushing the cache forces it to look for a fresh route.

On Windows:

ipconfig /flushdns

On macOS:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

If that fails, try switching your network settings to a reliable public DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1).

3. Audit Your npm Registry URL

A simple typo in your configuration can point npm toward a non-existent server. Check your current settings with this command:

npm config get registry

If the result isn't https://registry.npmjs.org/, reset it to the official default:

npm config set registry https://registry.npmjs.org/

4. Manage Corporate Proxy Settings

Corporate environments are notorious for this error. If you are behind a work firewall, npm needs specific instructions to pass through. Conversely, if you just left the office, a "ghost" proxy setting might still be active.

Check for active proxies:

npm config get proxy
npm config get https-proxy

Clear them (if you are on a home network):

npm config delete proxy
npm config delete https-proxy

Set them (if your office requires it):

npm config set proxy http://username:password@proxy.company.com:8080
npm config set https-proxy http://username:password@proxy.company.com:8080

5. Toggle VPNs and Firewalls

VPNs often hijack DNS resolution. If yours is active, toggle it off and try npm install again. Some aggressive antivirus software can also flag Node.js processes as suspicious, silently blocking their outbound traffic.

6. The "Nuclear" Cache Clean

While ENOTFOUND is a network error, a corrupted local cache occasionally causes npm to act erratically. Clear the deck with this command:

npm cache clean --force

Test the Connection

Don't just keep running your install command. Use the built-in npm ping to verify the fix:

npm ping

A successful fix will return npm notice PING https://registry.npmjs.org/ 185ms. Once you see that 200 OK status, your packages should download without a hitch.

Prevention and Pro Tips

Most ENOTFOUND errors come from switching between network environments. When I am setting up a new server or troubleshooting a complex local network, I double-check my parameters to ensure everything is aligned.

I often use the Subnet Calculator from ToolCraft to verify my machine's IP and gateway settings. It is a quick, browser-based tool that keeps your data private while you work through infrastructure headaches.

To avoid future issues, use environment variables for your proxy settings. This prevents you from hardcoding a work proxy into your .npmrc, which is the most common reason for this error popping up when you try to work from a coffee shop later.

Related Error Notes