Cannot assign requested address (EADDRNOTAVAIL) Networking Origin: Network OSI layer 4 · Transport Last updated 5 Nov 2026

Networking: connect: Cannot assign requested address — ephemeral port range exhausted by TIME_WAIT connections

The machine ran out of local ports for new outgoing connections to the same destination.

Exact message you may see Cannot assign requested addressconnect: Cannot assign requested addressOSError: [Errno 99] Cannot assign requested addressError: connect EADDRNOTAVAIL
Seen on: Linux Node.js Python Networking

Meaning

Each connection needs a unique source IP:port pair per destination, and closed connections linger in TIME_WAIT. Reuse connections (keep-alive, pools), widen net.ipv4.ip_local_port_range, add more source IPs, and avoid opening a new connection per request.

Common causes

  • No connection pooling or keep-alive
  • Huge connection churn to one destination
  • Small ephemeral port range
  • Many sockets in TIME_WAIT
  • Behind a single NAT/proxy IP

⚡ Quick fix

  1. Count: ss -tan state time-wait | wc -l
  2. Reuse connections / enable keep-alive
  3. sysctl -w net.ipv4.ip_local_port_range="10240 65535"

Detailed fix by platform

Linux

  1. ss -tan state time-wait | wc -l; sysctl net.ipv4.ip_local_port_range

How to diagnose

  1. TIME_WAIT — Thousands?
  2. Port range — Wide enough?
  3. Connections — Reused?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

4-way handshake timeout / Incorrect password — Networking: wlan0: WPA: 4-way handshake failed - pre-shared key may be incorrect / WRONG_KEY (Networking)4-way handshake timeo…arp -a shows (incomplete) — Networking: `arp -n` shows (incomplete) / Destination Host Unreachable — no ARP reply from the next hop (Networking)arp -a shows (incompl…Connections hang on large transfers (PMTU black hole) — Networking: SSH/HTTPS connects but hangs on large data — path MTU discovery black hole (Networking)Connections hang on l…DHCPDISCOVER: no free leases — Networking: dhcpd: DHCPDISCOVER from aa:bb:cc:dd:ee:ff via eth0: network 192.168.1.0/24: no free leases (Networking)DHCPDISCOVER: no free…High TCP retransmissions / packet loss — Networking: netstat -s: segments retransmitted / Wireshark: TCP Retransmission, TCP Dup ACK — packet loss on the path (Networking)High TCP retransmissi…MAC flapping / broadcast storm (spanning tree loop) — Networking: %SW_MATM-4-MACFLAP_NOTIF: Host is flapping between ports / broadcast storm (Networking)MAC flapping / broadc…Many sockets in CLOSE_WAIT — Networking: Thousands of sockets in CLOSE_WAIT — the application is not closing its side of the connection (Networking)Many sockets in CLOSE…NAT gateway SNAT port exhaustion (ErrorPortAllocation) — Networking: NAT gateway ErrorPortAllocation / SNAT port exhaustion — intermittent outbound connection timeouts (Networking)NAT gateway SNAT port…Cannot as…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.