---
title: "Change the RDP port on Windows without locking yourself out · CloudSat"
description: "Move Remote Desktop off port 3389 in the right order: open the new port first, change the registry, restart the service, test, then close the old rule."
url: https://cloudsat.io/learn/change-rdp-port-without-lockout
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Windows Server](https://cloudsat.io/learn/topic/windows)

# Change the RDP port on Windows without locking yourself out

Move Remote Desktop off port 3389 in the right order: open the new port first, change the registry, restart the service, test, then close the old rule.

CloudSat team November 18, 2026 6 min read

Every Windows server with Remote Desktop on port 3389 gets a steady stream of password guesses from automated scanners. Moving RDP to another port cuts most of that noise. It takes four commands, and the only real danger is the order: change the port before the firewall knows about it, and the next connection you make goes nowhere.

## What a new port does, and what it does not

Be clear about the goal before you start:

| Threat | Does a new port help? | What actually fixes it |
| --- | --- | --- |
| Bots guessing passwords on 3389 | Yes, most of them only try the default | Strong passwords, an account lockout policy |
| Someone scanning every port on your IP | No, a full scan finds RDP in minutes | A firewall rule that only admits your address |
| An unpatched RDP vulnerability | No | Windows updates, Network Level Authentication |
| A leaked password | No | A new password, a VPN or gateway in front |

So treat the port change as housekeeping: fewer failed logons in the Security log, less load, cleaner alerts. The protection comes from the measures at the end of this guide.

## Pick a port that will stay free

Choose a number between 1024 and 49151 that nothing else on the server uses. Stay out of 49152 to 65535: Windows hands those ports out for its own outgoing connections, and a clash can stop the RDP listener from starting. This guide uses 41389.

Check that the port is free and not reserved:

```powershell
Get-NetTCPConnection -LocalPort 41389 -ErrorAction SilentlyContinue   # no output means unused
netsh int ipv4 show excludedportrange protocol=tcp                    # ranges reserved by Hyper-V and others
```

If 41389 falls inside one of the excluded ranges, pick another number. Those reservations are a common cause of a listener that silently fails to bind.

## The safe order

1. Keep your current RDP session open. It survives until the service restarts.
2. Allow the new port in any cloud or network firewall in front of the server.
3. Allow the new port in Windows Defender Firewall.
4. Change the listening port in the registry.
5. Restart the Remote Desktop service. This ends your session.
6. Connect on the new port.
7. Only then remove the rules for 3389.

Steps 2 and 3 come first because they are harmless on their own: an open port with nothing listening costs nothing. Doing step 4 first is how people lock themselves out.

## Change it with PowerShell

Run PowerShell as administrator on the server. First check which network profile Windows applied, because a firewall rule created for the wrong profile does nothing:

```powershell
Get-NetConnectionProfile | Select-Object InterfaceAlias, NetworkCategory
```

Cloud servers usually show **Public**. The rules below use `-Profile Any` so the profile does not matter:

```powershell
$port = 41389

# Allow the new port: TCP carries the session, UDP is RDP's faster transport
New-NetFirewallRule -DisplayName "Remote Desktop $port (TCP-In)" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow -Profile Any
New-NetFirewallRule -DisplayName "Remote Desktop $port (UDP-In)" -Direction Inbound -Protocol UDP -LocalPort $port -Action Allow -Profile Any

# Point the listener at the new port
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name PortNumber -Value $port

# Restart Remote Desktop Services; your session drops here
Restart-Service -Name TermService -Force
```

`-Force` is needed because another service, the Remote Desktop Services UserMode Port Redirector, depends on `TermService`. A full reboot works too.

If you prefer Registry Editor, the value is `PortNumber` under `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp`. Switch the edit dialog to **Decimal** before typing: it opens in hexadecimal, and typing 41389 there gives a completely different port.

## Reconnect on the new port

Every client takes the port after a colon:

```text
mstsc /v:203.0.113.10:41389          Remote Desktop Connection on Windows
203.0.113.10:41389                   the PC name in Windows App (macOS, iOS, Android)
xfreerdp3 /v:203.0.113.10:41389      FreeRDP on Linux
full address:s:203.0.113.10:41389    the line inside a saved .rdp file
```

If the connection fails, test the path from your own computer before you change anything else:

```powershell
Test-NetConnection -ComputerName 203.0.113.10 -Port 41389
```

`TcpTestSucceeded : True` means the network is fine and the problem is on the RDP side. False means a firewall is still closed, or nothing listens on that port.

## Close the old door

Once you are signed in on the new port, disable the built-in rules, which only cover 3389, and remove 3389 from the cloud firewall:

```powershell
Disable-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP', 'RemoteDesktop-UserMode-In-UDP'

# Confirm what is listening now
Get-NetTCPConnection -State Listen | Where-Object LocalPort -in 3389, 41389
```

Only 41389 should appear. Update saved `.rdp` files, password manager entries and any monitoring checks that still point at 3389.

## If you lock yourself out anyway

A wrong port, a firewall rule on the wrong profile or a reserved range all look the same from outside: a timeout. The fix is the same too. Get to the server's console without the network, set `PortNumber` back to 3389, and restart `TermService`.

On CloudSat, the **Windows** firewall preset only allows 3389, so add the new port in the firewall first ([Create and apply cloud firewalls](https://cloudsat.io/docs/cloud-firewalls)), and if you still lose the connection, **Console access (VNC)** in the server's **Access** tab reaches the desktop regardless of firewall rules ([recovery tools](https://cloudsat.io/docs/recovery-tools)).

## What actually protects Remote Desktop

The port change is done. These steps do the real work:

- **Limit the source.** A firewall rule that admits only your office or home address stops nearly all attacks, whatever the port.
- **Keep Network Level Authentication on.** Attackers then never reach a sign-in screen. See [enabling Remote Desktop](https://cloudsat.io/learn/enable-remote-desktop-on-windows-server) for the setting.
- **Lock out repeated failures.** `net accounts /lockoutthreshold:10 /lockoutwindow:15 /lockoutduration:15` locks an account for 15 minutes after 10 bad passwords. On many Windows versions the built-in Administrator account is exempt from lockout.
- **Use long, unique passwords**, and give each person a named account of their own instead of sharing Administrator.
- **Put a VPN or gateway in front** when your address changes often. WireGuard or an RD Gateway means RDP never faces the internet directly.
- **Watch the log.** Failed sign-ins are event 4625 in the Security log:

```powershell
Get-WinEvent -FilterHashtable @{LogName = 'Security'; Id = 4625} -MaxEvents 20 |
  Select-Object TimeCreated, @{n = 'Account'; e = { $_.Properties[5].Value }}, @{n = 'From'; e = { $_.Properties[19].Value }}
```

### Or take RDP off the internet entirely

If only you connect, you do not need a public RDP port at all. Windows Server 2019 and later include an OpenSSH server as an optional feature. Install it, allow TCP 22 from your address only, and close every RDP rule:

```powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service -Name sshd -StartupType Automatic
Start-Service sshd
```

From your computer, open a tunnel and point the Remote Desktop client at your own machine:

```bash
ssh -N -L 33389:localhost:41389 Administrator@203.0.113.10
# then connect the RDP client to localhost:33389
```

The session travels inside SSH, and scanners see no Remote Desktop port anywhere. Use SSH keys rather than a password for the tunnel, or you have only moved the guessing game to port 22.

## FAQ

### Does changing the RDP port require a reboot?

No. Restarting the Remote Desktop Services service applies it. A reboot also works and is the simplest option when you change the value in Registry Editor.

### Do I need the UDP rule?

RDP works over TCP alone, but it uses UDP when it can for smoother video and typing on lossy connections. Open both, as Microsoft's own instructions do.

### Does this work on Windows 10 and 11?

Yes, on the Pro, Enterprise and Education editions that can host Remote Desktop. The registry value, firewall commands and client syntax are identical.

### Which port number is best?

None is safer than another. Pick an unused port below 49152 that you will remember, and skip obvious neighbors of the default such as 3390 or 33389.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Windows Server](https://cloudsat.io/learn/topic/windows)

- [Enable Remote Desktop on Windows Server 2016 to 2025](https://cloudsat.io/learn/enable-remote-desktop-on-windows-server): Windows Server Enable Remote Desktop on Windows Server 2016 to 2025 7 min read
- [RDP 'An internal error has occurred': causes and fixes](https://cloudsat.io/learn/fix-rdp-an-internal-error-has-occurred): Windows Server RDP 'An internal error has occurred': causes and fixes 6 min read
- [RDP server buyer's checklist: admin rights, licensing, speed](https://cloudsat.io/learn/rdp-server-buyers-checklist): Windows Server RDP server buyer's checklist: admin rights, licensing, speed 6 min read
- [DISM RestoreHealth and SFC: repair a Windows server image](https://cloudsat.io/learn/repair-windows-image-dism-sfc): Windows Server DISM RestoreHealth and SFC: repair a Windows server image 6 min read
