Node.js cannot listen: EADDRNOTAVAIL address not available
Error: listen EADDRNOTAVAIL: address not available 203.0.113.10:3000Short answer
EADDRNOTAVAIL is the operating system saying the address you asked to bind is not local: no network interface on this machine has it. In Node.js this comes from the host argument of listen(). Bind to an address the machine really has, or leave the host out so Node listens on all interfaces.
Fix it fast
1Find out which cause you have
Compare the address in the error with the addresses on the machine. If it is not in the list, that is the whole problem.
ip -brief address2Match what you see, then jump to its fix
- 1
The address in the error is a public IP, the IP of another server, or one copied from a config for a different machineThe host is a public or remote IP the machine does not ownFix - 2
It worked before a reboot, a new network, a VPN connection or a new container, and the host is hard-coded or in .envThe IP or interface changed since the setting was writtenFix
- 1
What does the error look like?
Error: listen EADDRNOTAVAIL: address not available 203.0.113.10:3000
Cause 1 of 2
The host is a public or remote IP the machine does not own
1Check
A public IP, or an address of another machine, is not assigned to any interface here. The bind(2) manual page defines EADDRNOTAVAIL as the requested address not being local.
ip -brief address
grep -rn "listen(" server.js src/ 2>/dev/null2Fix
Bind to 0.0.0.0, or to the private address from the first command. Omitting the host works too: Node's docs say the server then listens on the unspecified IPv6 address :: when IPv6 is available, and otherwise on 0.0.0.0.
server.listen(3000, '0.0.0.0', () => {
console.log('listening on 3000');
});3Verify
The server starts and answers on the port.
curl -I http://127.0.0.1:3000Confirmed by man7.org
Cause 2 of 2
The IP or interface changed since the setting was written
1Check
A LAN address from DHCP, a VPN adapter or a Docker network can disappear. The same manual page lists a nonexistent interface as a reason for EADDRNOTAVAIL.
ip -brief address
grep -rn "HOST" .env 2>/dev/null2Fix
Read the host from configuration with a safe default, and avoid pinning a changing address.
const host = process.env.HOST || '0.0.0.0';
const port = Number(process.env.PORT) || 3000;
server.listen(port, host);3Verify
Restart the app after removing the stale HOST value.
ss -ltn | grep 3000Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Treat the listen host as configuration with a default of 0.0.0.0, and control exposure with a firewall or reverse proxy.
- Print the host and port the server bound to at startup, so a wrong value is visible in the first log line.
- Never copy production IP addresses into local config files.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fixBack end
fluent-ffmpeg cannot find the ffmpeg or ffprobe binary
Error: Cannot find ffprobe
fluent-ffmpeg does not bundle ffmpeg.
4 causes, each with a fix