EADDRNOTAVAIL
Linux / POSIXERRORNotableNetworkHIGH confidence

Cannot Assign Requested Address

Production Risk

Common in containerized environments where IPs differ from host network.

What this means

EADDRNOTAVAIL (errno 99) is returned when bind() or connect() specifies an address that is not available on the local machine — either the IP address does not belong to any local interface, or the port is unavailable.

Why it happens
  1. 1bind() to an IP address not assigned to any local interface
  2. 2connect() specifying a local address (SO_BINDTODEVICE) that does not exist
  3. 3bind() to a port that is not in the local ephemeral range
How to reproduce

bind() to an IP not assigned to this host.

trigger — this will error
trigger — this will error
struct sockaddr_in addr = {
  .sin_family = AF_INET,
  .sin_port = htons(8080),
  .sin_addr.s_addr = inet_addr("10.0.0.5")  // not on this host
};
bind(sockfd, (struct sockaddr*)&addr, sizeof(addr));
// Returns -1, errno = EADDRNOTAVAIL

expected output

bind: Cannot assign requested address (EADDRNOTAVAIL)

Fix

Bind to an address assigned to this host

WHEN When specifying a local address in bind()

Bind to an address assigned to this host
// Bind to all interfaces
addr.sin_addr.s_addr = INADDR_ANY;  // 0.0.0.0

// Or list actual interface addresses first:
ip addr show

Why this works

INADDR_ANY binds to all local interfaces. Verify the specific IP is assigned locally with `ip addr`.

Sources
Official documentation ↗

Linux Programmer Manual bind(2)

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Linux / POSIX errors