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.
| Port | Protocol | Used for | Open it when |
|---|---|---|---|
| 3389 | TCP | The RDP session itself, always | You connect straight to the Windows machine |
| 3389 | UDP | An optional UDP transport for screen, audio and video | You want smoother sessions on weak links |
| 443 | TCP | RDP wrapped in HTTPS to a Remote Desktop Gateway | You connect through a gateway |
| 3391 | UDP | The UDP transport through a Remote Desktop Gateway | You 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.
grep 3389 /etc/servicesms-wbt-server 3389/tcpHow 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.
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.
Get-NetTCPConnection -State Listen -LocalPort 3389A 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.
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.
Get-NetTCPConnection -LocalPort 13389 -ErrorAction SilentlyContinue
Get-NetUDPEndpoint -LocalPort 13389 -ErrorAction SilentlyContinueNo 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.
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=udpPick 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.
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber' -Value 13389Change 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.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TcpOpen 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.
Restart-Service -Name TermService -ForceRestarting 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.
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 13389The 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.
Get-NetFirewallRule -DisplayName 'RDP 13389 TCP','RDP 13389 UDP' | Select-Object DisplayName, Enabled, Profile, Direction, ActionOn 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.
New-NetFirewallRule -DisplayName 'RDP 13389 TCP office' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 13389 -RemoteAddress 203.0.113.25Replace 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.
| Client | What to type |
|---|---|
| Remote Desktop Connection on Windows | 203.0.113.10:13389 in the Computer box |
| Windows command line | mstsc /v:203.0.113.10:13389 |
| Windows App on Mac, iPhone and Android | 203.0.113.10:13389 in the PC name field |
| FreeRDP on Linux | xfreerdp /v:203.0.113.10:13389 /u:Administrator |
| Remmina on Linux | 203.0.113.10:13389 in the Server field |
| A saved .rdp file | the 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.
Test-NetConnection -ComputerName 203.0.113.10 -Port 13389Look 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.
nc -zv 203.0.113.10 13389
nc -zv -w 3 203.0.113.10 3389Connection to 203.0.113.10 13389 port [tcp/*] succeeded!
nc: connect to 203.0.113.10 port 3389 (tcp) failed: Connection refusedThe 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.
nmap -Pn -sV -p 3389,13389 203.0.113.10PORT STATE SERVICE VERSION
3389/tcp closed ms-wbt-server
13389/tcp open ms-wbt-server xrdpWithout -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.
| Step | What to do | Why |
|---|---|---|
| 1 | Check you can reach the server another way, such as the provider console | It is your way back in if anything goes wrong |
| 2 | Add the firewall rules for the new port, in Windows and outside it | The new port is allowed before the listener moves |
| 3 | Change PortNumber | Nothing happens yet |
| 4 | Restart TermService or reboot | The service moves and your session drops |
| 5 | Connect on the new port and run the outside test | Proof that the change works |
| 6 | Only now remove or disable the rules for 3389 | The 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.
| Measure | What it stops |
|---|---|
| Firewall rule limited to your IP addresses | Connections from every other source address |
| Network Level Authentication left on | A full remote session being set up before the user has signed in |
| Long unique passwords and an account lockout policy | Password guessing |
| A VPN or Remote Desktop Gateway in front, with the firewall allowing only its addresses | Direct public access to the RDP listener |
| Windows updates applied | Known 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.
| What you see | Likely cause | Fix |
|---|---|---|
| Connection refused | Nothing is listening on that port | Check PortNumber and qwinsta, then restart TermService |
| Listener will not start on the new port | Another program already holds that port | Find it with the two commands below, then pick another port |
| Timeout with no answer | A firewall is dropping the packets | Add the rule in Windows and in the outside firewall |
| Port open but the client cannot connect | The client is still using 3389 | Add :13389 after the address |
| Works inside the network only | The router or cloud firewall was not updated | Forward or allow the new port there |
| Port open and sign in rejected | Not a port problem | Check 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.
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
- Microsoft Learn, Change the Remote Desktop listening port on your computer
- Microsoft Learn, Enable Remote Desktop on your PC
- IANA Service Name and Transport Protocol Port Number Registry, port 3389
- Microsoft Learn, Ports that are used by Remote Desktop Services
- Microsoft Learn, General Remote Desktop connection troubleshooting
- Microsoft Learn, The default dynamic port range for TCP/IP
- Microsoft Learn, Test-NetConnection
- Microsoft Learn, New-NetFirewallRule
- Nmap reference guide, service and version detection