How to Change the Remote Desktop (RDP) Port
A guide to customizing the default RDP listening port on Windows Server.
By default, Remote Desktop listens on port 3389. Administrators often change this to enhance security ("security through obscurity") or to resolve port conflicts.
⚠️ CRITICAL WARNING:
Before you restart the service or the server, you MUST configure the Windows Firewall to allow traffic on the new port. Failure to do so will lock you out of the server remotely.
Method 1: The Manual Method (Registry + Firewall)
This method involves manually editing the Windows Registry and creating a new firewall rule.
Step 1: Modify the Registry
- Open the Registry Editor by pressing Win + R, typing
regedit, and pressing Enter. - Navigate to the following path:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
- Locate the key named PortNumber in the right pane.
- Double-click it, select Decimal as the base, and type your new port number (e.g.,
3390). - Click OK.
Step 2: Update Windows Firewall
- Open Windows Defender Firewall with Advanced Security.
- Click on Inbound Rules > New Rule.
- Select Port and click Next.
- Select TCP and enter your specific local port (e.g.,
3390). - Select Allow the connection.
- Apply the rule to Domain, Private, and Public profiles (as needed).
- Name the rule (e.g., "RDP Custom Port 3390") and click Finish.
Step 3: Restart Service
Restart the server to apply changes. Alternatively, restart the Remote Desktop service:
Restart-Service TermService -Force
Method 2: Using PowerShell (Recommended)
This is the safest and fastest way, as it handles the registry and firewall in one go.
Run the following script as Administrator. (Replace 3390 with your desired port):
$port = 3390 # 1. Set the new port in Registry Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name "PortNumber" -Value $port # 2. Create the Firewall Rule New-NetFirewallRule -DisplayName "RDP Custom Port $port" -Direction Inbound -LocalPort $port -Protocol TCP -Action Allow # 3. Restart the Service Restart-Service TermService -Force
How to Connect with a Custom Port
Once changed, you must specify the port number when connecting via Remote Desktop Connection (mstsc.exe).
Syntax: ServerIP:PortNumber
Example: 192.168.1.10:3390
Author Bio
Microsoft Certified Professional
With over 20 years of experience deploying and managing enterprise Windows Server environments, Keloth leads technical implementation at RDS CAL Store. He specializes in Remote Desktop Services infrastructure, secure remote architecture, and helping IT teams seamlessly scale their official licensing.
Related Posts
How to Create a Remote Desktop User in Windows Server (2016, 2019, 2022 & 2025)
Home – How to Create a Remote Desktop User in Windows Server (2016, 2019, 2022 & 2025) How to Create a Remote Desktop User in Windows Server (2016, 2019, 2022 & 2025) Provisioning remote access for a new employee requires more than just creating a standard Windows account. To securely connect to a Session Host,…
How to Fix the CredSSP “Encryption Oracle Remediation” RDP Error
Home – How to Fix the CredSSP “Encryption Oracle Remediation” RDP Error How to Fix the CredSSP “Encryption Oracle Remediation” RDP Error If you are managing Windows Servers, you have likely encountered this terrifying error message when trying to connect via Remote Desktop: “An authentication error has occurred. The function requested is not supported… This…
How to Configure the RDS “Startup Environment” in Server 2016, 2019, 2022 & 2025
Home – How to Configure the RDS “Startup Environment” in Server 2016, 2019, 2022 & 2025 How to Configure the RDS “Startup Environment” in Server 2016, 2019, 2022 & 2025 If you recently upgraded your infrastructure, you likely noticed a glaring omission: Microsoft removed the Environment, Sessions, and Remote Control tabs from the Active Directory…
How to configure “Licensing Mode” and “License Server to Use” on a Windows Server
Home – How to configure “Licensing Mode” and “License Server to Use” on a Windows Server Configuring RDS Licensing Mode and License Server A guide for Windows Server 2016, 2019, 2022, and 2025. Configuring the Remote Desktop Services (RDS) licensing mode and license server on a Windows Server is a critical step for allowing more…