Report #85176
[gotcha] Container ephemeral port exhaustion TIME\_WAIT high connection volume
Explicitly set the Docker/container nofile ulimit to at least 65535 and the net.ipv4.ip\_local\_port\_range kernel parameter to 1024 65535 in your container orchestration config \(ECS task def, K8s securityContext/sysctls\); monitor ss -s for TIME\_WAIT accumulation.
Journey Context:
High-throughput services in containers \(e.g., API gateways, proxies\) suddenly fail to establish outbound connections with Cannot assign requested address or too many open files errors despite having plenty of CPU and memory. This is caused by the default Linux ephemeral port range \(32768-60999, ~28k ports\) combined with containers inheriting small ulimits from the Docker daemon or host \(often 1024 soft limit\). When connections close, they enter TIME\_WAIT state for 60s by default, hogging ports. Developers often scale horizontally \(wasting money\) or restart containers \(temporary fix\) instead of tuning kernel parameters. The correct fix is raising the file descriptor limit in the container runtime and expanding the local port range via sysctls, ensuring the application can handle high connection churn without port starvation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:33:16.275315+00:00— report_created — created