Summary
Port 3389 is the home of the remote desktop protocol used by all recent versions of Windows to enable Remote Desktop Services. If you have Remote Desktop enabled on your machine, it is listening on port 3389 for connections.
It is recommended to change the default RDP port to protect your system from bots and script kiddies.
You can change the listening port on Windows computers by modifying the registry.
Steps to change the Remote Desktop server port:
1] Type Regedit in the Search box and start the registry editor by clicking on the regedit editor icon.
2] Navigate to HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet> Control> Terminal Server> WinStations> RDP-Tcp, in Registry Editor.
3] Click on RDP-Tcp, and you will see PortNumber on the right side of the window panel.
4] Now, Right-click on the PortNumber and select Modify.
5] Change the Base to Decimal and enter a new port between 1025 and 65535 that is not already in use.
6] Click OK and reboot.
The new port must be entered the next time you connect to this machine using the Remote Desktop connection. If you use a firewall, be sure to set it to allow connections to the new port number.
PowerShell command to check the current port:
Get-ItemProperty -Path ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “PortNumber”
For Example:
PortNumber : 3389 PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations PSChildName : RDP-Tcp PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry
You can also modify the RDP port by performing the PowerShell code below. In this command, the new port number provided is 3390.
$portvalue = 3390 Set-ItemProperty -Path ‘HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp’ -name “PortNumber” -Value $portvalue New-NetFirewallRule -DisplayName ‘RDPPORTLatest-TCP-In’ -Profile ‘Public’ -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue New-NetFirewallRule -DisplayName ‘RDPPORTLatest-UDP-In’ -Profile ‘Public’ -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
And that’s how you change the listening port for the remote desktop on your computer.