Adjust TCP Dynamic Port Timeout in Regedit
When a Windows system experiences heavy network traffic, outbound
connections can rapidly consume all available dynamic ports, leading to
port exhaustion. By default, closed TCP connections remain in a
TIME_WAIT state for four minutes (240 seconds) to ensure
all packets are received before the port is recycled. This guide
explains how to adjust the system-wide dynamic port timeout using the
Windows Registry Editor (regedit) to reduce the
TIME_WAIT duration and free up ports much faster.
Steps to Modify the TCP Dynamic Port Timeout
- Open Registry Editor
- Press
Win + Ron your keyboard to open the Run dialog. - Type
regeditand press Enter (or click OK). - Click Yes if prompted by User Account Control (UAC).
- Press
- Navigate to the TCP/IP Parameters Key
In the Registry Editor address bar, paste the following path and press Enter:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
- Create or Modify
TcpTimedWaitDelay- Check the right-hand pane for a value named
TcpTimedWaitDelay. - If it does not exist:
- Right-click an empty space in the right pane.
- Select New > DWORD (32-bit) Value.
- Name the value
TcpTimedWaitDelay.
- Double-click
TcpTimedWaitDelayto edit it.
- Check the right-hand pane for a value named
- Set the Timeout Value
- Under Base, select Decimal.
- In the Value data field, enter the desired timeout
duration in seconds:
- Minimum recommended:
30(30 seconds) - Default:
240(4 minutes) - Valid range:
30to300
- Minimum recommended:
- Click OK to save the changes.
- Restart the System
- Close the Registry Editor.
- Restart your computer or server for the registry changes to take effect system-wide.
Optional:
Increase Dynamic Port Range (MaxUserPort)
If shortening the timeout delay does not fully resolve port exhaustion, you can increase the total number of user-accessible dynamic ports in the same registry location:
- In
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, right-click and choose New > DWORD (32-bit) Value. - Name it
MaxUserPort. - Double-click it, set the Base to
Decimal, and enter a value between
5000and65534(e.g.,65534to allocate the maximum allowable ports). - Click OK and restart your system.