Skip to content

RDPGuide

What Port Does RDP Use and How to Change It

  • Updated
  • 8 min read
  • VPS Lane Engineering
Short answer

RDP uses TCP port 3389 by default, with UDP 3389 as an optional extra transport. Windows keeps the number in the PortNumber registry value.

How we tested this

Port checks run on Ubuntu 24.04.5 LTS with nmap 7.94 and OpenBSD netcat against a live RDP listener. Windows steps follow the Microsoft documentation listed under Sources.

RDP Port Numbers at a Glance

The RDP port numbers below cover the two setups you will meet, a direct connection and one through a Remote Desktop Gateway.

This guide applies to Windows editions that can host Remote Desktop, meaning Windows 10 and 11 Pro, Enterprise and Education and supported Windows Server versions. Windows Home can connect out but cannot accept incoming Remote Desktop sessions.

Ports used by Remote Desktop
PortProtocolUsed forOpen it when
3389TCPThe RDP session itself, alwaysYou connect straight to the Windows machine
3389UDPAn optional UDP transport for screen, audio and videoYou want smoother sessions on weak links
443TCPRDP wrapped in HTTPS to a Remote Desktop GatewayYou connect through a gateway
3391UDPThe UDP transport through a Remote Desktop GatewayYou use a gateway and want its UDP transport

TCP 3389 is the only port a plain Remote Desktop connection needs. Everything else in the table is optional or belongs to a gateway. A gateway keeps its own ports, so changing the port on a Windows host does not change the ports the gateway listens on. The gateway must still reach the host on its new port, so update the firewall and the gateway settings between the two.

What the Default RDP Port 3389 Does

The default RDP port is 3389, registered with IANA under the service name ms-wbt-server for both TCP and UDP.

When you turn on Remote Desktop, the Remote Desktop Services service (TermService) starts listening on TCP 3389. The session normally starts over TCP, and clients and servers that support it can then negotiate a UDP transport on the same port number.

UDP is optional. If a firewall blocks UDP 3389 the session falls back to TCP. UDP can make the screen feel more responsive on links with delay or packet loss, and how much it helps depends on the network and on what you do in the session.

Linux knows the same name. This is the full match from /etc/services on Ubuntu 24.04, which is why port tools label 3389 as ms-wbt-server. That file is only a local list of names and here it carries the TCP line alone, while the IANA registry lists both protocols.

bash
grep 3389 /etc/services
Output
ms-wbt-server	3389/tcp

How to Check the RDP Port on Windows

To check the RDP port on Windows, read the PortNumber value from the registry in an administrator PowerShell window.

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

On a machine that was never changed the command reports PortNumber : 3389. That is the port the service will use the next time it starts.

The registry shows the setting. To see what is listening right now, ask the network stack instead.

powershell
Get-NetTCPConnection -State Listen -LocalPort 3389

A row in the output means something is listening on that port. An error saying no matching objects were found means nothing is, either because Remote Desktop is off or because the port was moved. If the cmdlet is missing on an older system, netstat -ano -p tcp | findstr LISTENING | findstr :3389 lists only the listening entry and shows the process ID in the last column.

To confirm the Remote Desktop listener itself is up, run qwinsta. A line named rdp-tcp with the state Listen means the listener is running.

How to Change the RDP Port in Windows

To change the RDP port you edit one registry value, restart one service and open the new port in the firewall, in a safe order.

Changing the port does not turn Remote Desktop on or give anyone access. Remote Desktop must already be enabled and your account allowed to use it.

Back Up the Registry Key First

Back up the registry key before you edit it, so a wrong value can be undone by importing the file again.

powershell
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" "$env:USERPROFILE\Desktop\RDP-Tcp-backup.reg"

This key is the default listener, named RDP-Tcp. A server with more than one Remote Desktop listener has one key per listener, so change the one you actually connect to.

Pick a Port Number That Is Free

A free port number between 1024 and 49151 that no other service is registered for is the safe choice. This guide uses 13389 as its example, a number with no entry in the Linux or nmap service lists. Look your own choice up in the IANA registry, then check that nothing on the server holds it on TCP or UDP.

powershell
Get-NetTCPConnection -LocalPort 13389 -ErrorAction SilentlyContinue
Get-NetUDPEndpoint -LocalPort 13389 -ErrorAction SilentlyContinue

No output from either command means no TCP connection or UDP endpoint is using that local port right now. It shows current use only. Windows can also reserve ranges of ports, which these commands list for IPv4 and IPv6.

powershell
netsh int ipv4 show excludedportrange protocol=tcp
netsh int ipv4 show excludedportrange protocol=udp
netsh int ipv6 show excludedportrange protocol=tcp
netsh int ipv6 show excludedportrange protocol=udp

Pick a number outside any range shown. Staying below 49152 also keeps you clear of the default range Windows uses for outgoing connections, which an administrator can change. Avoid numbers other software expects, such as 3306, 5432, 5900, 8080 or 8443.

Change the Port With PowerShell

PowerShell changes the port in one line, run as administrator.

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

Change the Port in Registry Editor

Registry Editor does the same job if you prefer clicking. Press Windows key and R, type regedit and go to this key.

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

Open PortNumber, switch Base to Decimal, type the new port and press OK. Leaving the base on Hexadecimal is a common mistake, because a number typed as hex lands on a different port. 3389 entered as hex, for example, becomes port 13193.

Apply the New Port

The new port applies when Remote Desktop Services restarts, so nothing changes until you restart the service or reboot.

powershell
Restart-Service -Name TermService -Force

Restarting the service disconnects every Remote Desktop session on the machine, including yours and those of other users. Open the firewall first, as shown next, and on a busy server pick a quiet time and make sure you have console access.

Open the New RDP Port in the Firewall

The new RDP port stays unreachable until a firewall rule allows it, because the standard built in Remote Desktop rules only cover 3389.

powershell
New-NetFirewallRule -DisplayName 'RDP 13389 TCP' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 13389
New-NetFirewallRule -DisplayName 'RDP 13389 UDP' -Direction Inbound -Action Allow -Protocol UDP -LocalPort 13389

The TCP rule is the one you must have. The UDP rule is optional and allows the UDP transport on the new number. Confirm both rules exist and are enabled.

powershell
Get-NetFirewallRule -DisplayName 'RDP 13389 TCP','RDP 13389 UDP' | Select-Object DisplayName, Enabled, Profile, Direction, Action

On a computer joined to a domain, group policy can override local firewall rules, so check with whoever manages that policy if the rule has no effect.

Limit the Rule to Your Own IP Address

Your own IP address in the rule means this rule only lets that one address through to the port.

powershell
New-NetFirewallRule -DisplayName 'RDP 13389 TCP office' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 13389 -RemoteAddress 203.0.113.25

Replace 203.0.113.25 with the public address you connect from. Use this instead of the open TCP rule, not as well as it, because a wider rule for the same port still lets everyone in. Keep the address current if your connection gets a new one, and treat the rule as an extra layer on top of sign in security, not a replacement for it.

Remember the Firewall Outside Windows

A firewall outside Windows needs the same change. That means a cloud security group, a hosting panel firewall or a port forward on a home router, each of which blocks the new port until you add it there too.

Connect to RDP With a Custom Port

To connect to RDP with a custom port, add a colon and the port number after the address in any client.

The addresses in this guide, 203.0.113.10 for the server and 203.0.113.25 for your own connection, are documentation examples. Replace them with your real addresses.

How each client takes a custom RDP port
ClientWhat to type
Remote Desktop Connection on Windows203.0.113.10:13389 in the Computer box
Windows command linemstsc /v:203.0.113.10:13389
Windows App on Mac, iPhone and Android203.0.113.10:13389 in the PC name field
FreeRDP on Linuxxfreerdp /v:203.0.113.10:13389 /u:Administrator
Remmina on Linux203.0.113.10:13389 in the Server field
A saved .rdp filethe line full address:s:203.0.113.10:13389

With no port given, a direct connection assumes 3389. That is why a connection that worked yesterday fails after a port change until you add the number.

Test the RDP Port From Another Machine

Test the RDP port from another machine, because a check run on the server itself skips the firewalls in between.

From Windows

Windows has a port test built in to PowerShell.

powershell
Test-NetConnection -ComputerName 203.0.113.10 -Port 13389

Look at the last line. TcpTestSucceeded : True means a TCP connection was made. False means it could not be made, which can be a firewall, no listener, a wrong address, a routing problem or a server that is down. A pass only proves the port is reachable, so finish with a real Remote Desktop sign in to prove the whole path.

From Linux or macOS

Linux and macOS can run the same check with netcat. These results were captured on Ubuntu 24.04.5 against an xrdp 0.9.24 listener that had been moved from 3389 to 13389, with the address swapped for the example one.

bash
nc -zv 203.0.113.10 13389
nc -zv -w 3 203.0.113.10 3389
Output
Connection to 203.0.113.10 13389 port [tcp/*] succeeded!
nc: connect to 203.0.113.10 port 3389 (tcp) failed: Connection refused

The new port accepts the connection and the old one refuses it, which is exactly what a finished change looks like. A check that hangs until the timeout, with no "refused", usually points at a firewall dropping packets or a routing problem, so check the firewalls and the address before the service.

Confirm It Is Really RDP

To confirm it is really RDP answering and not some other program, ask nmap to identify the service.

bash
nmap -Pn -sV -p 3389,13389 203.0.113.10
Output
PORT      STATE  SERVICE       VERSION
3389/tcp  closed ms-wbt-server
13389/tcp open   ms-wbt-server xrdp

Without -sV nmap only looks the port number up in its list and reports 13389 as unknown. With it, nmap sends probes and matches the reply against its list of known services, so the name depends on that list. The listener in this test was xrdp on Linux. A Windows host normally shows as Microsoft Terminal Services in the same column.

Avoid a Lockout When Changing the RDP Port

A lockout when changing the RDP port happens when the service moves before the firewall does, so do the steps in this order.

Safe order for changing the RDP port on a remote server
StepWhat to doWhy
1Check you can reach the server another way, such as the provider consoleIt is your way back in if anything goes wrong
2Add the firewall rules for the new port, in Windows and outside itThe new port is allowed before the listener moves
3Change PortNumberNothing happens yet
4Restart TermService or rebootThe service moves and your session drops
5Connect on the new port and run the outside testProof that the change works
6Only now remove or disable the rules for 3389The old port closes last

If you are locked out anyway, sign in through the console, set PortNumber back to 3389 with the same PowerShell command, and restart the service. The built in firewall rules for 3389 are still there unless you removed them, which is the reason step 6 comes last.

Does Changing the RDP Port Make It Safer

Changing the RDP port makes the logs quieter but does not make Remote Desktop safe on its own.

Automated scanners that only try 3389 will pass a moved port by, which cuts the failed sign in noise in your logs. A scan that includes the new port still finds it, and the nmap test above shows the service being identified as RDP on a number that is not the default. Treat a custom port as noise reduction, not as protection.

These measures do the real work, in order of effect.

What actually protects an RDP port
MeasureWhat it stops
Firewall rule limited to your IP addressesConnections from every other source address
Network Level Authentication left onA full remote session being set up before the user has signed in
Long unique passwords and an account lockout policyPassword guessing
A VPN or Remote Desktop Gateway in front, with the firewall allowing only its addressesDirect public access to the RDP listener
Windows updates appliedKnown Remote Desktop flaws

If you want a Windows desktop that is already set up this way, a hosted Windows RDP server comes with full administrator access so you control the port and the firewall yourself.

When RDP Still Fails on the Right Port

When RDP still fails on the right port, the test result tells you where to look.

Reading a failed RDP port test
What you seeLikely causeFix
Connection refusedNothing is listening on that portCheck PortNumber and qwinsta, then restart TermService
Listener will not start on the new portAnother program already holds that portFind it with the two commands below, then pick another port
Timeout with no answerA firewall is dropping the packetsAdd the rule in Windows and in the outside firewall
Port open but the client cannot connectThe client is still using 3389Add :13389 after the address
Works inside the network onlyThe router or cloud firewall was not updatedForward or allow the new port there
Port open and sign in rejectedNot a port problemCheck the user is allowed to use Remote Desktop

To see which program holds a port, take the number under OwningProcess from the first command and put it in place of 1234 in the second.

powershell
Get-NetTCPConnection -LocalPort 13389 -State Listen | Select-Object LocalAddress, LocalPort, State, OwningProcess
tasklist /svc /FI "PID eq 1234"

Questions people ask

What port does RDP use?

RDP uses port 3389 by default, on TCP for the session and on UDP for a faster optional transport.

Is RDP TCP or UDP?

Both. TCP carries the connection, on port 3389 unless you changed it. Clients and servers that support it also negotiate UDP on the same port.

How do I find my RDP port number?

Run Get-ItemProperty on the RDP-Tcp registry key in PowerShell and read PortNumber. A machine that was never changed shows 3389.

Do I need to restart after changing the RDP port?

Yes. Restart the Remote Desktop Services service or reboot. The registry change alone does nothing until the service starts again.

How do I connect to RDP on a different port?

Add a colon and the port after the address, for example 203.0.113.10:13389. It works the same in the Windows, Mac, mobile and Linux clients.

Should I open UDP 3389 as well as TCP?

TCP is required and UDP is optional. Allow UDP on the same port if you want the UDP transport, and RDP falls back to TCP when it is blocked.

Does changing the RDP port make it secure?

No. It only cuts automated scanning noise. Real protection comes from firewall limits, Network Level Authentication, strong passwords and updates.

Is it safe to leave port 3389 open to the internet?

Not without limits. Restrict the firewall rule to your own IP addresses or put a VPN or gateway in front, whatever port number you use.

Sources

  1. Microsoft Learn, Change the Remote Desktop listening port on your computer
  2. Microsoft Learn, Enable Remote Desktop on your PC
  3. IANA Service Name and Transport Protocol Port Number Registry, port 3389
  4. Microsoft Learn, Ports that are used by Remote Desktop Services
  5. Microsoft Learn, General Remote Desktop connection troubleshooting
  6. Microsoft Learn, The default dynamic port range for TCP/IP
  7. Microsoft Learn, Test-NetConnection
  8. Microsoft Learn, New-NetFirewallRule
  9. Nmap reference guide, service and version detection

Written and tested by VPS Lane EngineeringWe run every step on real servers before publishing and update the guide when the software changes.