How to fix npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available in npm
This error occurs when npm or Node.js attempts to bind to an IP address that doesn't exist on your machine. It's typically caused by incorrect network configuration, dynamic IP changes, or proxy issues.
Quick fix
Fixes npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
echo $HOST
echo $HOSTNAME- Check and clear the HOST environment variable
- Verify your current IP address and network configuration
- Update your npm registry configuration to use default settings
- Configure proxy settings if behind a corporate proxy
echo $HOSTecho $HOSTNAMEnpm ERR! code EADDRNOTAVAILnpm ERR! errno EADDRNOTAVAILnpm ERR! Address not available
What this error means
EADDRNOTAVAIL (Address Not Available) is a network error that occurs when a Node.js application or npm registry client tries to establish a connection or bind to a socket using an IP address that is not actually assigned to your system. This usually happens when the HOST environment variable points to an IP address that no longer exists, was never valid on your machine, or when attempting to bind to an interface that isn't available in your network environment. The error indicates a mismatch between the configured network address and what your system actually has available. This is particularly common in dynamic network environments where IP addresses change (like DHCP), or when running applications in containerized/virtualized environments.
Typical symptoms
- npm install fails with 'EADDRNOTAVAIL' error message
- npm start or other npm scripts fail when trying to bind to a specific port
- Error appears after machine restart or network reconnection
- Application works on some machines but fails with EADDRNOTAVAIL on others
- VPN connection changes trigger the error
Common causes
- HOST environment variable is set to an IP address that doesn't exist on your current machine
- Network IP address changed due to DHCP lease renewal or router restart
- Attempting to bind to a private IP address inside a container or virtualized environment
- npm configured to run behind a corporate proxy with incorrect proxy settings
- Connecting through a VPN that changes available network interfaces
How to fix "npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available"
First, verify if a HOST environment variable is configured that might be causing the issue.
On Linux/macOS:
echo $HOST
echo $HOSTNAMEOn Windows (PowerShell):
$env:HOST
$env:HOSTNAMEIf you find a problematic HOST variable, unset it:
On Linux/macOS:
unset HOSTOn Windows (PowerShell):
Remove-Item env:HOSTCheck what IP addresses are actually assigned to your machine:
On Linux/macOS:
ifconfig
# or
ip addr showOn Windows:
ipconfigMake sure any IP address you're trying to bind to actually appears in this list. If it doesn't, that's why you're getting EADDRNOTAVAIL.
If you have custom npm registry or network settings, reset them to defaults:
npm config list
npm config delete registry
npm config delete https-proxy
npm config delete proxy
npm config delete http-proxy
npm config set registry https://registry.npmjs.org/Alternatively, remove or rename your .npmrc file:
mv ~/.npmrc ~/.npmrc.backup
npm installIf you're behind a corporate proxy, configure npm to use it properly:
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080You can also set environment variables:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
npm installFor applications (not npm install), if binding to a specific IP is required, use 0.0.0.0 to listen on all available interfaces instead:
// Instead of:
app.listen(3000, '192.168.1.100')
// Use:
app.listen(3000, '0.0.0.0')
// Or for localhost only:
app.listen(3000, '127.0.0.1')If running in a container, always use 0.0.0.0 since the container doesn't have access to your host machine's private IP addresses.
Advanced notes
EADDRNOTAVAIL commonly occurs in containerized environments (Docker, Kubernetes) because the container is isolated from the host network. If you're running npm inside a container, always configure applications to listen on 0.0.0.0 rather than specific IP addresses. For ephemeral port exhaustion issues, increase your system's port range: on Linux, check cat /proc/sys/net/ipv4/ip_local_port_range and increase it if needed.
Frequently asked questions
- What does "npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Addr" mean?
- js application or npm registry client tries to establish a connection or bind to a socket using an IP address that is not actually assigned to your system. This usually happens when the HOST environment variable points to an IP address that no longer exists, was never valid on your machine, or when attempting to bind to an interface that isn't available in your network environment. The error indicates a mismatch between the configured network address and what your system actually has available.
- How do I fix "npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Addr"?
- This error occurs when npm or Node.js attempts to bind to an IP address that doesn't exist on your machine. It's typically caused by incorrect network configuration, dynamic IP changes, or proxy issues.
- What causes "npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Addr"?
- HOST environment variable is set to an IP address that doesn't exist on your current machine Network IP address changed due to DHCP lease renewal or router restart Attempting to bind to a private IP address inside a container or virtualized environment
- Is the "npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Addr" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: Node.js Error Codes(Official Docs)
- ๐ฌSO: Address not available(Stack Overflow)
- ๐GitHub: npm issues(GitHub)