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.


Step-by-Step Configuration Guide

Step 1: Open the Registry Editor

  1. Press Windows Key + R to open the Run dialog box.
  2. Type regedit and press Enter or click OK.
  3. 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

  1. Check the right-hand pane to see if the MaxUserPort value already exists.
  2. 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 MaxUserPort and press Enter.
  3. Double-click the MaxUserPort entry to edit it.
  4. Under Base, select the Decimal radio button.
  5. In the Value data field, enter the highest port number you want the dynamic range to reach (for example, 65534 to maximize available ports).
  6. 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:

  1. In the same registry directory, check for the TcpTimedWaitDelay value.
  2. If it does not exist, right-click, select New > DWORD (32-bit) Value, and name it TcpTimedWaitDelay.
  3. Double-click TcpTimedWaitDelay, select Decimal, and set the value between 30 and 240 (seconds). The default is 240 (4 minutes); setting it to 30 frees up ports much faster.
  4. 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 tcp

This command will output the current start port and total number of dynamic ports available for TCP communication.