TECH / Windows 2 min read

How to Change the RDP Port in Windows 10, 11, and Windows Server

Antonio NEMCD Author
Published May 30, 2009 · 2 min

If a Windows PC or Windows Server is exposed to the internet over Remote Desktop (RDP), automated brute-force bots hammer default port 3389 around the clock. Moving RDP to a custom port isn’t a replacement for a VPN, yet it instantly cuts out 99% of noisy login spam in your security event logs.

Editing RDP PortNumber in Windows Registry Editor

The exact same registry value works across every version of Windows – from classic Windows XP and Server 2008/2012 right through Windows 10, 11, and Windows Server 2019/2022/2025.

Order matters: always open the new port in Windows Firewall (and in your cloud provider’s security group or router) before restarting Remote Desktop Services – otherwise you can lock yourself out of a remote server.

Method 1. Via Registry Editor (regedit)

  1. Open Registry Editor: press Win + R, type regedit, and hit Enter.
  2. Navigate to RDP-Tcp: open HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp.
  3. Edit PortNumber: double-click PortNumber on the right, switch the base to Decimal, and enter your chosen free port (for example 33890 – ideally somewhere in the 10000–65000 range).
  4. Allow the port in Windows Firewall: run wf.msc -> Inbound Rules -> New Rule -> Port -> TCP (and optionally a second rule for UDP transport) -> enter 33890 -> Allow the connection.

Method 2. Fast PowerShell Script (Registry + Firewall + Restart)

On Windows 10/11 or Windows Server, four lines in an elevated PowerShell prompt handle everything cleanly (replace 33890 with your preferred port):

$port = 33890
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name "PortNumber" -Value $port
New-NetFirewallRule -DisplayName "RDP Custom TCP $port" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow
New-NetFirewallRule -DisplayName "RDP Custom UDP $port" -Direction Inbound -Protocol UDP -LocalPort $port -Action Allow
Restart-Service TermService -Force

How to Connect After Changing the Port

You don’t need a full server reboot – restarting TermService applies the new port immediately (your current RDP window will briefly disconnect). In Remote Desktop Connection (mstsc), append the new port after a colon:

203.0.113.10:33890

For real production security, still put RDP behind WireGuard or Tailscale – or restrict the inbound firewall rule strictly to your own static IP address.

Related posts:

Leave a Comment