Change the Remote Desktop Port

Remote Desktop listens on port 3389. Moving it to another port does not make the server secure, but it reduces the number of bots trying passwords. For real protection see Allow Remote Desktop Only From Your IP Addresses.

⚠ Open the new port first

If the firewall does not allow the new port, you cannot connect any more after the restart. Follow the steps in this order. If you lock yourself out, use Console Access under Information for a VPS, or noVNC / IPMI for a dedicated server.

1. Check the current port

Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name PortNumber

The current Remote Desktop port 3389

2. Allow the new port, then change it

Open PowerShell (Admin) and run, with your own port number (for example 53389):

New-NetFirewallRule -DisplayName "Remote Desktop 53389" -Direction Inbound -Protocol TCP -LocalPort 53389 -Action Allow
New-NetFirewallRule -DisplayName "Remote Desktop 53389 UDP" -Direction Inbound -Protocol UDP -LocalPort 53389 -Action Allow
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name PortNumber -Value 53389
Restart-Service TermService -Force

Your session is disconnected. Connect again with the port after the address, for example 203.0.113.91:53389.


Related Guides

View all Windows guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)