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.
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.
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.
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.
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 CERT_SIGNATURE_FAILURE npm ERR! Certificate signature failure
How to fix 'npm ERR! code CERT_SIGNATURE_FAILURE' certificate signature failure