This guide provides a step-by-step process for changing the Remote Desktop Protocol (RDP) port on Windows Server versions 2016, 2019, and 2022. Follow these instructions carefully to ensure a smooth transition to a new RDP port configuration, while also setting up necessary firewall rules.
Step 1: open the registry editor
To begin changing the RDP port, access the Registry Editor by typing regedit into the Windows search bar, which will open the Registry Editor.
Step 2: navigate to the RDP TCP settings
Select the Registry Editor. Navigate to the RDP TCP port settings through the Registry Editor by accessing the HKEY_LOCAL_MACHINE directory.
Step 3: access the system directory
Within HKEY_LOCAL_MACHINE, proceed to the System directory. Navigate to CurrentControlSet, then access the Control folder. Within Control, locate the TerminalServer directory.
Step 4: locate the terminal server directory
Locate and select TerminalServer within the Control directory.
Step 5: open the RDP TCP settings
From TerminalServer, go to WnStations, and then select RDP-TCP. Identify the file labeled PortNumber. Right-click on PortNumber, select MODIFY.
Step 6: modify the RDP port number
Choose the DECIMAL option and input the new port number. Once entered, confirm by clicking OK. If WINDOWS FIREWALL is enabled, proceed to open WINDOWS FIREWALL.
Step 7: open Windows firewall advanced settings
Within WINDOWS FIREWALL, navigate to ADVANCED SETTINGS, then proceed to INBOUND RULES. Here, create a new rule rather than searching for the PORT NUMBER.
Step 8: create a new inbound rule for the new port
To create a new rule, click NEW RULE, select PORT, and then click NEXT.
Step 9: specify the new TCP port
Opt for TCP and enter the new port number in SPECIFIC LOCAL PORTS. Click NEXT and choose to allow the connection.
Step 10: allow the connection
Select ALLOW THE CONNECTION, click NEXT. In the profile section, maintain the default settings and click NEXT again.
Step 11: name and finish the firewall rule
Name this rule and then click FINISH.
Step 12: reboot the server
To complete the process, reboot the server. Click START, then select the restart icon and choose RESTART.
Notes
The steps for each file in the directory path to get to RDP TCP can be condensed into a single step as such:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP