How to fix npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 765 views

This error occurs when npm cannot resolve the DNS address for the npm registry. Common causes include network connectivity issues, misconfigured DNS servers, incorrect proxy settings, or VPN/firewall interference blocking the connection.

Quick fix

Fixes ENOTFOUND

# Try pinging a reliable host
ping 8.8.8.8

# Try resolving the npm registry
nslookup registry.npmjs.org

# Or on systems without nslookup
host registry.npmjs.org
  1. Verify internet connectivity
  2. Check and remove proxy settings
  3. Explicitly set the npm registry
  4. Change your DNS servers
npm โ€” error
# Try pinging a reliable host
ping 8.8.8.8
# Try resolving the npm registry
nslookup registry.npmjs.org
# Or on systems without nslookup
host registry.npmjs.org
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org

What this error means

The ENOTFOUND error in npm indicates a DNS resolution failure - your system cannot translate the registry hostname (registry.npmjs.org) into an IP address. This is a network-level issue that prevents npm from even reaching the registry server. When you run `npm install`, npm first needs to resolve the domain name of the registry to its IP address using DNS. If this lookup fails, you'll see the ENOTFOUND error. The actual error originates from Node.js's `getaddrinfo` function, which performs the DNS lookup. This error is distinct from authentication errors (E401) or package-not-found errors (E404) - with ENOTFOUND, npm never successfully contacts the registry at all. The problem lies between your machine and the DNS resolution process.

Typical symptoms

  • npm install fails immediately with 'getaddrinfo ENOTFOUND registry.npmjs.org'
  • All npm commands that require network access fail with ENOTFOUND
  • Error occurs on all packages, not just specific ones
  • Ping to registry.npmjs.org also fails or times out
  • npm commands work on some networks but not others (e.g., office vs home)
  • Error appears after connecting to VPN or changing network settings

Common causes

  1. No internet connectivity or unstable network connection
  2. DNS server is misconfigured, unreachable, or returning incorrect results
  3. Incorrect proxy settings in .npmrc or environment variables
  4. VPN software interfering with DNS resolution
  5. Firewall or security software blocking outbound connections to registry.npmjs.org
  6. Corporate network requires specific proxy configuration
  7. Stale DNS cache pointing to old/invalid IP address
  8. Docker container has no DNS resolver configured
  9. CI/CD environment missing network configuration

How to fix "npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org"

1Verify internet connectivity

First, confirm you have basic internet access:

bash
# Try pinging a reliable host
ping 8.8.8.8

# Try resolving the npm registry
nslookup registry.npmjs.org

# Or on systems without nslookup
host registry.npmjs.org

If ping to 8.8.8.8 works but nslookup fails, you have a DNS problem. If both fail, you have a general connectivity issue.

You can also try opening https://registry.npmjs.org in a browser - if it loads, the issue is specific to how npm resolves DNS.

2Check and remove proxy settings

Incorrect proxy settings are a common cause. Check your current npm proxy configuration:

bash
npm config get proxy
npm config get https-proxy

If these return values and you're not behind a proxy, remove them:

bash
npm config delete proxy
npm config delete https-proxy

Also check for environment variables that might set proxy:

bash
# On macOS/Linux
echo $HTTP_PROXY
echo $HTTPS_PROXY
echo $NO_PROXY

# On Windows
echo %HTTP_PROXY%
echo %HTTPS_PROXY%

If these are set incorrectly, unset them:

bash
# On macOS/Linux
unset HTTP_PROXY
unset HTTPS_PROXY

# On Windows PowerShell
$env:HTTP_PROXY = ""
$env:HTTPS_PROXY = ""
3Explicitly set the npm registry

Sometimes the registry URL gets corrupted or set incorrectly. Reset it explicitly:

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

Verify the setting:

bash
npm config get registry

This should return exactly https://registry.npmjs.org/.

4Change your DNS servers

If your DNS server is the problem, switch to a public DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1):

On macOS:
1. Open System Preferences > Network
2. Select your network connection and click "Advanced"
3. Go to the DNS tab
4. Add 8.8.8.8 and 8.8.4.4 (or 1.1.1.1 and 1.0.0.1)

On Linux (Ubuntu/Debian):

bash
# Edit resolv.conf
sudo nano /etc/resolv.conf

# Add or replace nameserver lines:
nameserver 8.8.8.8
nameserver 8.8.4.4

Note: On systems using NetworkManager or systemd-resolved, changes to resolv.conf may be overwritten. Use your distribution's network settings GUI or configure the DNS server in your network manager.

On Windows:
1. Open Control Panel > Network and Internet > Network Connections
2. Right-click your connection and select Properties
3. Select "Internet Protocol Version 4" and click Properties
4. Choose "Use the following DNS server addresses"
5. Enter 8.8.8.8 and 8.8.4.4

After changing DNS, flush the DNS cache:

bash
# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Linux
sudo systemd-resolve --flush-caches

# Windows
ipconfig /flushdns
5Clear npm cache

Clearing the npm cache can resolve some network-related issues:

bash
npm cache clean --force

Then retry your npm command.

6Check your .npmrc file for issues

Review your .npmrc file for any problematic settings:

bash
# On macOS/Linux
cat ~/.npmrc

# On Windows
type %USERPROFILE%\.npmrc

Look for any registry, proxy, or other network-related settings that might be wrong. If in doubt, you can temporarily rename the file to test without it:

bash
mv ~/.npmrc ~/.npmrc.backup
npm install

If npm works without .npmrc, review the file's contents and remove problematic lines.

7Disable VPN or security software temporarily

VPNs and security software (antivirus, firewalls) can interfere with DNS resolution:

1. Temporarily disconnect from your VPN
2. Disable any firewall or security software
3. Try running npm install again

If npm works after disabling these, you'll need to configure exceptions:

- VPN: Configure split tunneling to exclude npm registry traffic, or use the VPN's DNS servers
- Firewall: Allow outbound connections to registry.npmjs.org on ports 443 (HTTPS) and 80 (HTTP)
- Corporate proxy: Get the correct proxy settings from your IT department

Advanced notes

### Docker and Container Environments

Docker containers may not have DNS configured correctly by default:

dockerfile
# In Dockerfile, explicitly set DNS
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf

Or when running the container:

bash
docker run --dns 8.8.8.8 your-image

For Docker Compose:

yaml
services:
  app:
    dns:
      - 8.8.8.8
      - 8.8.4.4

### CI/CD Pipeline Configuration

In CI/CD environments, you may need explicit registry configuration:

GitHub Actions:

yaml
- name: Setup npm registry
  run: |
    npm config set registry https://registry.npmjs.org/
    npm config set strict-ssl true

GitLab CI:

yaml
before_script:
  - npm config set registry https://registry.npmjs.org/

### Corporate Network / Proxy Configuration

If you're behind a corporate proxy, configure npm to use it:

bash
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

# If the proxy requires authentication
npm config set proxy http://username:password@proxy.company.com:8080

For NTLM proxies, you may need a local proxy tool like Cntlm.

### IPv6 Issues

Some networks have broken IPv6 that can cause DNS issues. Try disabling IPv6 for npm:

bash
npm config set prefer-offline false
npm config set prefer-online true

Or system-wide on Linux:

bash
# Temporarily disable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1

### Using a Mirror Registry

If the main npm registry is unreachable from your location, try a mirror:

bash
# Taobao mirror (popular in China)
npm config set registry https://registry.npmmirror.com

# Or use yarn with a different registry
yarn config set registry https://registry.npmmirror.com

Remember to switch back to the official registry when the issue is resolved:

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

### Debugging with Verbose Output

To see exactly what's happening during the DNS resolution:

bash
npm install --loglevel verbose

Or check npm's debug log:

bash
cat ~/.npm/_logs/*-debug.log | tail -100

### WSL (Windows Subsystem for Linux)

WSL can have DNS resolution issues. Check if DNS is properly inherited from Windows:

bash
cat /etc/resolv.conf

If the nameserver looks wrong, you can configure WSL to generate resolv.conf differently by editing /etc/wsl.conf or manually setting nameservers.

Frequently asked questions

What does "ENOTFOUND" mean?
org) into an IP address. This is a network-level issue that prevents npm from even reaching the registry server. When you run npm install, npm first needs to resolve the domain name of the registry to its IP address using DNS.
How do I fix "ENOTFOUND"?
This error occurs when npm cannot resolve the DNS address for the npm registry. Common causes include network connectivity issues, misconfigured DNS servers, incorrect proxy settings, or VPN/firewall interference blocking the connection.
What causes "ENOTFOUND"?
No internet connectivity or unstable network connection DNS server is misconfigured, unreachable, or returning incorrect results Incorrect proxy settings in .npmrc or environment variables
Is the "ENOTFOUND" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading