Skip to content
Home » RDP & Remote Access » How to Change Your RDP Port (and Why It Is Not Enough)

How to Change Your RDP Port (and Why It Is Not Enough)

Simple graphic showing how to change the RDP port from 3389 to a custom port, with Prixl branding and security icons representing reduced attack exposure.

You can change the RDP port on a Windows server in about fifteen minutes: one registry value, one firewall rule, a restart of Remote Desktop Services and a change on your router. This guide does it safely, with the commands. But read the first section before you start, because a port change is not the security fix many guides make it out to be, and getting it wrong can lock you out of your own server.

What a port change does, and what it does not

Remote Desktop listens on port 3389 by default. Moving it to another number means the crudest scanners, which only knock on 3389, stop finding it, and your Security log gets quieter.

That is all it does. The sign-in screen is still on the internet, still accepts any username and password, and is still open to any bug that works before sign-in. Some scanners check every port, and once they have found Remote Desktop on 38389 it goes on the same lists as 3389. Malwarebytes ran an RDP honeypot on a non-standard port and it still received about 10,000 password guesses a day; their conclusion was that changing the port “does not provide any meaningful protection” (Malwarebytes, 2022).

The real fix is to take Remote Desktop off the internet: Prixl Guard Secure Access, a VPN or RD Gateway, or at the least a firewall rule that allows only known IP addresses. Our RDP security guide puts these in order. Change the port afterwards if you want quieter logs, or as a stop-gap while the real fix is being set up.

Before you start

  • Have another way in. The keyboard and screen at the server, or your cloud provider’s console. If the new port does not work, that is how you fix it.
  • Pick a quiet time. Restarting Remote Desktop Services ends every Remote Desktop session on the server, including yours. Tell staff to save their work in Tally and sign out first.
  • Know who manages the router. In most offices the ISP router forwards the RDP port to the server. That forward has to change too, or nobody outside the office can connect.

Step 1: Choose the new port

Pick a number between 1024 and 49151 that nothing else on the server uses. Two rules:

  • Never use 49152 to 65535. That is Windows’ dynamic range, which it hands out for outgoing connections (Microsoft). If another program happens to be using your chosen port when Remote Desktop starts, RDP cannot listen on it.
  • Avoid ports other software uses, such as 9000 (TallyPrime’s default ODBC port), 1433 (SQL Server) or 5985 (WinRM).

We use 38389 in the examples. Check that it is free; no output means nothing is listening on it:

Get-NetTCPConnection -LocalPort 38389 -ErrorAction SilentlyContinue

Step 2: Add a scoped firewall rule first

Create the rule before you move the port, so the new port is reachable the moment Remote Desktop restarts. Do not create an “allow from anywhere” rule: limit it to your office network and the fixed IP addresses that really need it. In PowerShell, run as Administrator, with your own addresses in place of the examples:

New-NetFirewallRule -DisplayName "RDP Custom Port" -Direction Inbound -Protocol TCP -LocalPort 38389 -RemoteAddress LocalSubnet, 203.0.113.10, 198.51.100.25 -Action Allow -Profile Any
New-NetFirewallRule -DisplayName "RDP Custom Port UDP" -Direction Inbound -Protocol UDP -LocalPort 38389 -RemoteAddress LocalSubnet, 203.0.113.10, 198.51.100.25 -Action Allow -Profile Any

The UDP rule is optional (Remote Desktop falls back to TCP without it) but makes sessions smoother. In the GUI the same thing is Windows Defender Firewall with Advanced Security > Inbound Rules > New Rule > Port, TCP 38389, “Allow the connection”, then open the new rule’s Properties > Scope and add the allowed remote IP addresses.

Staff working from home on changing broadband addresses cannot be allow-listed this way. For them, use Guard or a VPN rather than opening the rule to everyone.

Step 3: Change the port in the registry

The port is stored in the PortNumber value under:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

In PowerShell (as Administrator), check the current value, then set the new one:

Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name PortNumber
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name PortNumber -Value 38389

Or in Registry Editor: open regedit, go to the key above, double-click PortNumber, choose Decimal, type the new number and click OK. Microsoft documents the same steps in Change the Remote Desktop listening port.

Step 4: Restart Remote Desktop Services

The new port takes effect when the service restarts. This ends every Remote Desktop session, so run it from the server’s console if you can:

Restart-Service -Name TermService -Force

If you are working over Remote Desktop, your session drops when you run it, and you reconnect on the new port. A server restart at a quiet time does the same job.

Step 5: Update the router or cloud firewall

On the office router, change the port-forward so it points to the server’s LAN address on 38389. If your router lets you limit a forward to certain source addresses, use the same list as Step 2. On a cloud server, update the security group or network security group instead.

A simpler alternative: leave the server on 3389 and change only the outside port on the router (forward outside 38389 to the server’s 3389). The noise reduction is the same and there is less to break on the server.

Step 6: Test, then close 3389

From an allowed location, open Remote Desktop Connection and enter the address with the port after a colon, for example office.example.com:38389. From the command line:

mstsc /v:office.example.com:38389

Once that works, close the old port. Disable the built-in Remote Desktop rules (they allow 3389) and delete the router’s old 3389 forward:

Disable-NetFirewallRule -DisplayGroup "Remote Desktop"

Finally, from a laptop on a phone hotspot, check what the outside world sees. The first test should fail (3389 closed) and, if you are testing from an allowed address, the second should succeed:

Test-NetConnection office.example.com -Port 3389
Test-NetConnection office.example.com -Port 38389

How to undo it

From the console, set PortNumber back to 3389, re-enable the built-in rules with Enable-NetFirewallRule -DisplayGroup "Remote Desktop", restart TermService, and put the router forward back. Then remove the custom rules with Remove-NetFirewallRule -DisplayName "RDP Custom Port", "RDP Custom Port UDP".

Why a new port is not enough

After the change your server still has an internet-facing sign-in. The things that actually get small offices broken into are untouched:

  • Guessed and reused passwords. Scanners that find the new port start guessing exactly as before. See how RDP brute-force attacks work.
  • Pre-sign-in bugs. Only patching and NLA help there.
  • No second factor. Windows Remote Desktop has no built-in MFA.

Guard Secure Access removes the exposed sign-in instead of moving it. Staff connect to the office server through an encrypted WireGuard tunnel using an invite you create in the Warden dashboard, then use Remote Desktop as normal; “Lock RDP to Secure Access only” then closes RDP to the internet. The default connection method needs no router port-forward and no static IP. Until that is in place, the steps in how to restrict RDP access safely keep the exposure as small as possible.

Whatever port you use, you still want to know who is trying it. Prixl Warden reads the Windows Security log and emails you about brute-force patterns, sign-ins outside working hours and new admin accounts, wherever RDP listens. Start your 30-day free trial and see what is already hitting your server.

Leave a Reply

Your email address will not be published. Required fields are marked *