How to Configure TCP/IP Dynamic Ports Using Regedit
This article provides a step-by-step guide on configuring custom dynamic (ephemeral) TCP/IP port ranges in Windows using the Registry Editor (Regedit). By adjusting these registry parameters, network administrators can expand the available port pool to prevent port exhaustion during heavy network traffic, or restrict the range to meet specific application and firewall requirements.
Understanding the Dynamic Port Registry Settings
In Windows, dynamic outbound connections select an available port
from a designated range. Through the Registry Editor, you can control
the upper boundary of this range using the MaxUserPort
setting.
- Registry Key:
MaxUserPort - Data Type:
REG_DWORD - Default Range: By default, dynamic ports start at
49152and end at65535. - Valid Values:
5000to65534(Decimal)
Step-by-Step Configuration Guide
Step 1: Open the Registry Editor
- Press
Windows Key + Rto open the Run dialog box. - Type
regeditand pressEnteror click OK. - If prompted by User Account Control (UAC), click Yes.
Step 2: Navigate to the TCP/IP Parameters Key
In the left-hand navigation pane, expand the folders to reach the following path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Step 3: Create or
Modify the MaxUserPort Value
- Check the right-hand pane to see if the
MaxUserPortvalue already exists. - If it does not exist:
- Right-click an empty area in the right-hand pane.
- Select New > DWORD (32-bit) Value.
- Name the new value
MaxUserPortand pressEnter.
- Double-click the
MaxUserPortentry to edit it. - Under Base, select the Decimal radio button.
- In the Value data field, enter the highest port
number you want the dynamic range to reach (for example,
65534to maximize available ports). - Click OK to save the changes.
Step 4: (Optional)
Configure TcpTimedWaitDelay
When expanding port availability, you can also reduce the time a
closed connection remains in the TIME_WAIT state:
- In the same registry directory, check for the
TcpTimedWaitDelayvalue. - If it does not exist, right-click, select New >
DWORD (32-bit) Value, and name it
TcpTimedWaitDelay. - Double-click
TcpTimedWaitDelay, select Decimal, and set the value between30and240(seconds). The default is240(4 minutes); setting it to30frees up ports much faster. - Click OK.
Step 5: Restart the System
Registry modifications under the Tcpip\Parameters subkey
do not take effect dynamically. Restart your computer or server to apply
the new TCP/IP port range settings.
Verifying the Changes
After the system reboots, you can verify your active dynamic port configuration by opening Command Prompt as an Administrator and running:
netsh int ipv4 show dynamicport tcpThis command will output the current start port and total number of dynamic ports available for TCP communication.