Replacing the default port 3389 of Windows Server via the registry

To change the default RDP port (3389) on Windows Server 2016/2019 through the registry, follow these steps:
  1. Open the Registry Editor by typing “regedit” in the search box in the Start menu or at the command prompt.
  2. Navigate to the following path:“HKEY_LOCAL_MACHINE\SYSTEM\ CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp”.
  3. Find the key named “PortNumber” and double-click on it.
  4. In the Value window, select Decimal and enter the new port number. For example, enter “5000” to change the port to 5000.
  5. Click OK to save the changes.
  6. Restart the server for the changes to take effect.
After the server reboots, RDP will listen on the new port you specified. When connecting to the server using RDP, you will need to specify a new port in the Computer field when entering the connection address. For example, if you use port 5000, the connection address should be “server_name:5000”.