Glossary · Networking

Port Exhaustion

Port exhaustion occurs when a host runs out of free ephemeral source ports for new outbound connections to a given destination.

Updated October 28, 2026

Port exhaustion happens when all local ephemeral ports are in use or still reserved, so the operating system cannot open another outbound connection to the same destination address and port. A connection is identified by source IP, source port, destination IP and destination port, and only the source port can vary.

Why it matters

The symptom is sudden connection failures, often Cannot assign requested address or timeouts, even though CPU and memory look fine. It hits reverse proxies, API clients and NAT gateways that make many short connections to one backend. The default Linux ephemeral range is roughly 28,000 ports, which limits sustained new connections per destination, especially while sockets sit in TIME_WAIT.

Example

Check the range and the current socket count:

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

Remedies in order of preference: reuse connections (keep-alive and pooling), spread load across more backend IPs or ports, and only then widen the range. Cloud NAT gateways have per-destination port limits too, so check your provider's documentation.

Common mistakes

  • Raising the port range without fixing the missing connection reuse.
  • Disabling keep-alive to the backend for simplicity.
  • Missing the problem because the error appears only under load tests.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.