How to Change the Default RDP Port

Written by

in

1. Overview

RDP (Remote Desktop Protocol) is a Microsoft protocol that allows you to remotely access and control a Windows computer over a network or the internet.

By default, RDP uses port 3389.

When you connect using the Remote Desktop Connection (mstsc.exe) application, your keyboard, mouse, and screen are transmitted to the remote computer, allowing you to control it through a graphical interface.

2. Enable RDP on a New Windows Server VM

Step 1: Enable Remote Desktop

  1. Open Start → Settings → System → Remote Desktop.
  2. Turn Enable Remote Desktop to On.
  3. Click Confirm when prompted.

RDP

Step 2: Allow RDP Through Windows Firewall

  1. Open Windows Defender Firewall.
  2. Click Allow an app or feature through Windows Defender Firewall.
  3. Make sure Remote Desktop is enabled for the required network profiles (Private and/or Public).

Step 3: Configure User Access

  1. Right-click This PC and select Properties.
  2. Click Remote Settings.
  3. Under Remote Desktop, click Select Users.
  4. Add the user accounts that should be allowed to connect through RDP.

3. Change the Default RDP Port

Step 1: Open Registry Editor

  1. Press Windows + R.
  2. Type regedit and press Enter.
  3. If prompted by User Account Control (UAC), click Yes.

Step 2: Locate the RDP Port Setting

Navigate to the following registry path:
HKEY_LOCAL_MACHINE
└─ System
└─ CurrentControlSet
└─ Control
└─ Terminal Server
└─ WinStations
└─ RDP-Tcp

Step 3: Change the Port Number

  1. In the right pane, locate PortNumber.
  2. Double-click PortNumber.
  3. Select Decimal under Base.
  4. Enter the new port number (for example, 3390 or 5000).
  5. Click OK.

Tip: Choose a port number between 1025 and 65535 that is not already in use.

Step 4: Allow the New Port Through Windows Firewall

  1. Open Windows Defender Firewall with Advanced Security.
  2. Select Inbound Rules.
  3. Click New Rule.
  4. Select Port, then click Next.
  5. Choose TCP and enter the new port number.
  6. Click Next.
  7. Select Allow the connection.
  8. Click Next.
  9. Select the required network profiles (Domain, Private, and/or Public).
  10. Click Next.
  11. Enter a name for the rule (for example, Custom RDP Port).
  12. Click Finish.

Step 5: Apply the Changes

Restart the server.

Or restart the Remote Desktop service using Command Prompt with administrative privileges:

Command Prompt
net stop termservice
net start termservice

Tip: Record the new RDP port number and verify that you can connect successfully before ending your current remote session. This helps prevent accidental loss of access to the server.