When a game server opens and closes short connections to the DB or other servers very often, closed connections hold their ports for a while, and new connections can’t be opened.
Why A new connection is opened and closed for every request → Effect The side that closes first holds the port for about 60 seconds on Linux (TIME_WAIT), and the pool of usable ports runs dry → On screen Internal requests fail: failed saves, broken features
Primary owner Game team (Server development) · Also Infra team (Server infrastructure)
Game team action items
Reuse connections (connection pool), stop opening and closing a new connection for every request.
Infra team action items
Widen the port range (ip_local_port_range), consider TIME_WAIT reuse for outgoing connections (tcp_tw_reuse on Linux), monitor the TIME_WAIT count.
Ballpark numbers
The default Linux port range (32768–60999) holds about 28,000 ports. More than 470 new connections per second to the same destination address use them up. Windows has about 16,000 ports by default (49152–65535) and a longer TIME_WAIT, so it runs out even faster.
On the graph
Hits a ceiling · TIME_WAIT sockets, internal connection failures
Where to look
TIME_WAIT sockets counted per destination address with ss -tan state time-wait, and connect failures (EADDRNOTAVAIL) in the game server log
Confirmed if
TIME_WAIT sockets to the same destination (the DB, for example) flatten near the size of the ephemeral port range (about 28,000 by default), and connect fails with EADDRNOTAVAIL
Ruled out if
Few TIME_WAIT sockets, but only outbound connections to the outside fail: “Cloud NAT gateway connection and port limits”
Check with
Infra tools (no game code needed)
Learn more
On Linux, the 60-second TIME_WAIT is hard-coded in the kernel. Lowering tcp_fin_timeout, which has a similar name, doesn’t shorten TIME_WAIT.
Sources
IP SysctlLinux kernel ip_local_port_range default 32768–60999; tcp_tw_reuse; tcp_fin_timeout is how long the FIN_WAIT_2 state is kept
TCP/IP port exhaustion troubleshootingMicrosoft Windows dynamic ports default to 49152–65535, and a closed connection holds its port in TIME_WAIT for 4 minutes by default