On Windows VPS and Admin RDP servers, Remote Desktop already listens on TCP port 3389. Most people never need to change it. If you want a different port, for example to match a company policy, follow the steps below. The order matters: open the new port in the firewall first, then move RDP.
Warning: If you change the port before allowing it in the firewall, your next connection will fail. Keep the browser console from the control panel in mind as your way back in, and keep your current session open until you have tested the new port.
1. Pick a port
Choose an unused port between 1025 and 65535, for example 49833. Avoid ports used by software you run (such as 1433 for SQL Server or 8080 for web apps). This guide uses 49833.
2. Allow the new port in Windows Firewall
Open PowerShell as Administrator:
New-NetFirewallRule -DisplayName "RDP 49833 TCP" -Direction Inbound -Protocol TCP -LocalPort 49833 -Action Allow
New-NetFirewallRule -DisplayName "RDP 49833 UDP" -Direction Inbound -Protocol UDP -LocalPort 49833 -Action Allow3. Change the RDP port
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name PortNumber -Value 49833
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name PortNumber4. Restart the Remote Desktop service
Restarting the service ends your current session, so check step 2 once more first. Then run:
Restart-Service -Name TermService -ForceIf the command reports that dependent services are running, restart the server instead with Restart-Computer.
5. Connect on the new port
Add the port after the IP address with a colon:
mstsc /v:203.0.113.25:49833In Windows App on Mac, iPhone or Android, enter 203.0.113.25:49833 as the PC name.
6. Close the old port
Once the new port works, disable the rule that allows the old port (3389 by default):
Get-NetFirewallPortFilter -Protocol TCP |
Where-Object LocalPort -eq 3389 |
Get-NetFirewallRule |
Disable-NetFirewallRuleTip: If you later restrict RDP to your own IP address, apply the restriction to your new rules (for example Set-NetFirewallRule -DisplayName "RDP 49833 TCP" -RemoteAddress 198.51.100.10).
Troubleshooting
- Timeout on the new port: open the browser console from the control panel, log in and check the rule with
Get-NetFirewallRule -DisplayName "RDP 49833*". - Want to undo it: set
PortNumberback to3389, re-enable the 3389 rule (the same pipeline as step 6 withEnable-NetFirewallRule) and restart the service.
