01
What the port changes, and what it does not
By default, Remote Desktop (RDP) listens on port 3389, over TCP and UDP. Bots scan the Internet constantly and try credentials on that port. Moving it to another number has a real but limited effect:
- What it brings: far fewer automated attempts, so cleaner logs and less risk of strangers getting an account locked.
- What it does not bring: a port scan finds the new number quickly. The port protects nothing if the password is weak.
Do the settings that matter first: an administrator account in your own name with a long password, Network Level Authentication (NLA) and a firewall that keeps Remote Desktop to your own IP addresses. They are described in securing a Windows VPS. Changing the port comes on top.
02
Before you start
03
Step 1: open the new port in the firewall
Order matters. If you change the port before opening the firewall, Remote Desktop will listen on a blocked port after the restart, and you will be locked out. Create the inbound rules first, for TCP and UDP, with the commands from Microsoft's documentation:
$portValue = 3390
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portValue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portValue
Get-NetFirewallRule -DisplayName 'RDPPORTLatest*' | Select-Object DisplayName, Enabled, Profile
- The profile: Microsoft's documentation adds
-Profile Public. Without that option, the rule applies to every profile (default value Any), which avoids a bad surprise if the VPS network adapter is not classified as Public.
- Your addresses: if you had restricted Remote Desktop to your IP addresses, do the same on the new rules by adding for example
-RemoteAddress 203.0.113.10 to each command. Otherwise the new port will be open to everyone.
- Another firewall: if a firewall also filters traffic between you and the VPS (a company one, for example), the new port must be allowed there too.
04
Step 2: change the port in the registry and restart
The listening port is the PortNumber value of the key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp. Display it, then change it:
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber'
$portValue = 3390
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber' -Value $portValue
With Registry Editor (regedit): open the same key, double-click PortNumber, select the Decimal base before typing the number (in hexadecimal, 3390 would become another port), then confirm.
Check one last time that the step 1 rules are enabled, then restart the VPS, as Microsoft instructs:
Restart-Computer
The session drops immediately. Allow a minute or two before reconnecting.
05
Step 3: connect with address:port
In Remote Desktop Connection (mstsc), enter the VPS IP address followed by a colon and the new port, for example 203.0.113.10:3390. Other Remote Desktop apps accept the same form. Remember to update your saved .rdp files.
If the connection fails, test the port from a Windows PC:
Test-NetConnection -ComputerName 203.0.113.10 -Port 3390
If TcpTestSucceeded is True, the port answers: check the username and password. If it is False, it means it is blocked or Remote Desktop is not listening: go through the console.
Once connected, the original Remote Desktop rules still let port 3389 through, where nothing listens any more. You can disable them:
Disable-NetFirewallRule -Name RemoteDesktop-UserMode-In-TCP,RemoteDesktop-UserMode-In-UDP
Rolling back from the console: set the value back to 3389, re-enable the original rules and restart.
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber' -Value 3389
Enable-NetFirewallRule -Name RemoteDesktop-UserMode-In-TCP,RemoteDesktop-UserMode-In-UDP
Restart-Computer
06
On CloudFive
CloudFive's Windows VPS, from €8.50 per month, comes with Windows Server, licence included, and Remote Desktop ready on port 3389: the address and username are on the VPS page.
- The customer area console stays available whatever port you choose: it is this guide's safety net.
- Snapshots are taken from the customer area, before each change of this kind.
- Ryzen 9 9950X, DDR5, NVMe, dedicated IPv4 address and basic anti-DDoS protection included, in France, monthly with no commitment, with support in French 7 days a week.
Next steps: connecting over Remote Desktop from each device, and transferring files to the VPS.
07
Frequently asked questions
How do I change the RDP port on Windows Server?
First open the new port for TCP and UDP in the firewall with New-NetFirewallRule. Then change the PortNumber value of the key HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp, restart the server and connect with address:port.
Is changing the RDP port enough to secure a Windows VPS?
No. The change cuts down automated attempts, but a port scan quickly finds the new number. A long password, Network Level Authentication and a firewall restricted to your IP addresses remain essential.
How do I connect to Remote Desktop on another port?
Add the port after the address, separated by a colon, for example 203.0.113.10:3390, in Remote Desktop Connection or in another Remote Desktop app. Also update the .rdp files you have saved.
What if I can no longer connect after changing the port?
Open the console from the customer area, which does not depend on Remote Desktop. Check the firewall rule for the new port, or set PortNumber back to 3389, re-enable the original rules and restart.
Which port should I choose for Remote Desktop?
A free port, not used by another service on the VPS, and outside the 49152 to 65535 range that Windows uses for outgoing connections. Check that it is free with Get-NetTCPConnection before choosing it.