| Important Considerations Before You Start: - Administrator Rights: You must be logged in as an administrator.
- Backup: It's always a good idea to back up your registry before making changes. You can do this by exporting the
RDP-Tcp key (Step 2) before modifying it. - Port Availability: Choose a port number that isn't already in use by another application and is within the valid range (1024-65535). Common alternatives include 3390, 4000, 5000, etc.
- Firewall: You must update your Windows Firewall (and any other network firewalls) to allow traffic on the new port.
For WindowsXP1. Start Registry Editor. 2. Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Win\Stations\RDP-Tcp\PortNumber 3. On the Edit menu, click Modify, and then click Decimal. 4. Type the new port number, and then click OK. 5. Quit Registry Editor. For Windows2000 or Windows20031. Run Regedt32 and go to this key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Win\Stations\RDP-Tcp NOTE: The above registry key is one path; it has been wrapped for readability. 2. Find the "PortNumber" subkey and notice the value of 00000D3D, hex for (3389). Modify the port number in Hex and save the new value.
To change the port for a specific connection on the Terminal Server:• Run Regedt32 and go to this key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Win\Stations\connection NOTE: The above registry key is one path; it has been wrapped for readability. 3. Find the "PortNumber" subkey and notice the value of 00000D3D, hex for (3389). Modify the port number in Hex and save the new value. If your OS version is Windows XP SP2 or higher, you have to check firewall setting. Basically every port is blocked by Microsoft Windows Firewall.
For Windows 10/11Step 1: Open Registry Editor 1. Press Win + R to open the Run dialog. 2. Type regedit and press Enter. 3. Click Yes if prompted by User Account Control (UAC). Step 2: Navigate to the RDP-Tcp Key 1. In the Registry Editor, navigate to the following path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp You can copy and paste this path directly into the address bar of Regedit in Windows 10/11 for quicker navigation. Step 3: Modify the PortNumber Value 1. In the right pane, locate the entry named PortNumber. 2. Double-click on PortNumber. 3. In the "Edit DWORD (32-bit) Value" window: - Select
Decimal under Base. This is crucial! If you leave it as Hexadecimal, your port number will be incorrect. - In the "Value data" field, enter your desired new port number (e.g.,
4000, 3390). - Click
OK.
Step 4: Close Registry Editor 1. Close the Registry Editor window. Step 5: Restart Your Computer 1. For the change to take effect, you must restart your computer. Step 6: Update Windows Firewall Rules (Crucial!) After restarting, your computer will now listen for RDP connections on the new port, but Windows Firewall will still be blocking it unless you update the rules. You have a couple of options: Option A: Using Windows Defender Firewall with Advanced Security (Recommended) 1. Press Win + R, type wf.msc, and press Enter. This opens "Windows Defender Firewall with Advanced Security." 2. In the left pane, select Inbound Rules. 3. Disable/Delete the Old RDP Rule: - Look for an existing rule named "Remote Desktop (TCP-In)" or similar, which usually allows port 3389.
- Right-click it and select
Disable Rule (or Delete if you're certain you won't revert to 3389).
4. Create a New Inbound Rule for Your New Port: - In the right pane (Actions), click
New Rule.... - Select
Port and click Next. - Select
TCP and then Specific local ports. Enter your new port number (e.g., 4000). Click Next. - Select
Allow the connection and click Next. - Select the network profiles where this rule should apply (e.g.,
Domain, Private, Public - usually you'd want all three for RDP, but adjust based on your security needs). Click Next. - Give the rule a descriptive name (e.g., "Remote Desktop - New Port 4000") and an optional description. Click
Finish.
Option B: Using PowerShell (Quicker for experienced users) 1. Right-click the Start button and select Windows Terminal (Admin) or PowerShell (Admin). 2. Run the following command, replacing [YourNewPort] with your chosen port number (e.g., 4000): New-NetFirewallRule -DisplayName "Remote Desktop (New Port)" -Direction Inbound -Protocol TCP -LocalPort [YourNewPort] -Action Allow
Example for port 4000: New-NetFirewallRule -DisplayName "Remote Desktop (Port 4000)" -Direction Inbound -Protocol TCP -LocalPort 4000 -Action Allow
3. (Optional) If you want to disable the old default RDP rule via PowerShell:
Disable-NetFirewallRule -DisplayName "Remote Desktop (TCP-In)"
Step 7: Test the New Port 1. From another computer, open the Remote Desktop Connection client (mstsc.exe). 2. In the "Computer" field, enter your target computer's IP address or hostname followed by a colon and the new port number. - Example:
192.168.1.100:4000 or MyWindowsPC:4000
3. Click Connect and verify that you can establish an RDP session. Connecting from Outside Your Local Network (If Applicable) If you plan to connect to your computer from the internet, you will also need to configure port forwarding on your router to direct traffic from the internet on your chosen port to the internal IP address of your Windows computer on the same port. This step is specific to your router's make and model. |