Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Node.js cannot listen: EADDRNOTAVAIL address not available

ErrorError: listen EADDRNOTAVAIL: address not available 203.0.113.10:3000

Short 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.

  • Applies to Node.js 22, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 address
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2It 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

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/null

2Fix

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:3000

Confirmed by man7.org

Did this fix it?

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/null

2Fix

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 3000

Confirmed by raw.githubusercontent.com

Did this fix it?

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.