Changing the Listening Port Number for Windows Remote Desktop (RDP)

Note: This guide requires you to modify the registry. Please be extremely careful to follow all instructions correctly, as improper edits to the registry may cause serious issues to a system.

Jump to your OS:

Windows 7

Step 1: Open the Registry Editor

Run the regedit command. You may do this by opening the Start Menu and typing "regedit" into the search bar. Select the option labeled "regedit" from the results list.

Start menu Regedit from start menu

Accept any prompts asking to allow the Registry Editor to make changes to your device.

Allow Regestrity Editor to make changes

Step 2: Navigate to the Proper Folder

Navigate to correct folder

The Registry Editor will now open on your computer. Navigate to the folder where the port number is stored by opening the folders on the left menu according to the following path:

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

Once in the folder, locate the field named "PortNumber".

Navigate to correct folder

Step 3: Enter a New Port Number

Right-click on the word "PortNumber" and select "Modify" from the menu that appears.

Select Modify option

Select the radio button labeled "Decimal" to view the port number value in the decimal number system. Change the value in the "Value data:" bar to the new port number you will use for Remote Desktop.

Do not use the default port 3389.

(Note: Port numbers range from 0 to 65535, though many ports between 0 and 999 are reserved for well-known services. Before changing your port number, check online that the port number you will be using is not reserved.)

Click "OK" when finished.

Change the value in decimal

The new port number should be visible in the "Data" section of the PortNumber field, written in the hexidecimal numbering system followed by the decimal number system equivalent in parenthesis. In the image below, the hexidecimal value is underlined in red, while the decimal value is underlined in green. Check that the decimal value is the port number you desired.

Check the new value of the port number

Step 4: Close Registry Editor and Restart

Quit the Registry Editor by clicking the red 'X' in the top right corner of the window. Restart your computer to solidify the changes.

Step 5: Add an Inbound Rule in Windows Defender Firewall

Open the Windows Firewall application with advanced security. You may do this by opening the Start Menu and typing "firewall" into the search bar. Select the option labeled "Windows Firewall with Advanced Security" from the results list.

Windows Firewall from start menu

After the Windows Firewall with Advanced Security window opens, select "Inbound Rules" from the left menu, then choose "New Rule..." from the right menu.

Select Inbound Rules and New Rule

In the Rule Wizard that appears, choose to create a "Port" rule before hitting "Next >".

Choose Port

On the next screen, choose "TCP" from the list of protocols. Select "Specific local ports:" and input the new port number that you entered in Step 3.

Again, do not use the default port 3389.

Hit "Next >" to continue to the next screen.

Choose TCP and specify a local port

Select "Allow the connection" from the list and hit "Next >".

Choose Allow the connection

Apply this rule to all options by checking off all boxes ("Domain", "Private", and "Public") and hitting "Next >".

Select all options

Name your rule with an informative title before hitting "Finish".

Name your rule

Your new rule should appear at the top of the list with the name you assigned it.

Check that the new rule exists

Connecting with the New Port

Run Remote Desktop Connection. You may do this by opening the Start Menu and typing "remote desktop" into the search bar. Select the option labeled "Remote Desktop Connection" from the results list.

Remote Desktop Connection from start menu

In the window that appears, enter the full hostname of the system being accessed, followed by a colon (:) and the new port number that you entered in Step 3. Hit "Connect" to finish.

(Note: Do not include spaces. A full hostname includes the domain names, ex: hostname.domain.domain.domain )

Enter full hostname with port number

Windows 10

Step 1: Open the Registry Editor

Run the regedit command. You may do this by opening the Start Menu and typing "regedit" into the search bar. Select the option labeled "regedit" with the words "Run command" below it.

(Note: The search bar in Windows 10 is not visible when the menu is first opened. To access the search bar, just start typing with the Start Menu open.)

Regedit from start menu

Alternatively, press the Windows Key + R. This will open the Run dialog box. Type "regedit" into the input bar labeled "Open:" and press "OK".

Regedit from Run dialog

Accept any prompts asking to allow the Registry Editor to make changes to your device.

Allow Regestrity Editor to make changes

Step 2: Navigate to the Proper Folder

The Registry Editor will now open on your computer. Navigate to the folder where the port number is stored by entering the the following path in the navigation bar at the top of the window:

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

Once in the folder, locate the field named "PortNumber".

Navigate to correct folder

Step 3: Enter a New Port Number

Right-click on the word "PortNumber" and select "Modify" from the menu that appears.

Select Modify option

Select the radio button labeled "Decimal" to view the port number value in the decimal number system. Change the value in the "Value data:" bar to the new port number you will use for Remote Desktop.

Do not use the default port 3389.

(Note: Port numbers range from 0 to 65535, though many ports between 0 and 999 are reserved for well-known services. Before changing your port number, check online that the port number you are changing it to is not a reserved port.)

Click "OK" when finished.

Change the value in decimal

The new port number should be visible in the "Data" section of the PortNumber field, written in the hexidecimal numbering system followed by the decimal number system equivalent in parenthesis. In the image below, the hexidecimal value is underlined in red, while the decimal value is underlined in green. Check that the decimal value is the port number you desired.

Check the new value of the port number

Step 4: Close Registry Editor and Restart

Quit the Registry Editor by clicking the red 'X' in the top right corner of the window. Restart your computer to solidify the changes.

Step 5: Add an Inbound Rule in Windows Defender Firewall

Open the Control Panel. You may do this by opening the Start Menu and typing "control panel" into the search bar. Select the option labeled "Control Panel" with the words "Desktop app" below it.

(Note: The search bar in Windows 10 is not visible when the menu is first opened. To access the search bar, just start typing with the Start Menu open.)

Control panel from start menu

When the Control Panel has opened, locate the search bar in the top right corner and enter "firewall".

Control Panel

Select "Windows Defender Firewall" from the search results.

Search for firewall in Control Panel

Select "Advanced settings" from the side menu.

Select advanced settings

In the pop-up window, select "Inbound Rules" from the left menu, then choose "New Rule..." from the right menu.

Select Inbound Rules and New Rule

In the Rule Wizard that appears, choose to create a "Port" rule before hitting "Next >".

Choose Port

On the next screen, choose "TCP" from the list of protocols. Select "Specific local ports:" and input the new port number that you entered in Step 3.

Again, do not use the default port 3389.

Hit "Next >" to continue to the next screen.

Choose TCP and specify a local port

Select "Allow the connection" from the list and hit "Next >".

Choose Allow the connection

Apply this rule to all options by checking off all boxes ("Domain", "Private", and "Public") and hitting "Next >".

Select all options

Name your rule with an informative title before hitting "Finish".

Name your rule

Your new rule should appear at the top of the list with the name you assigned it.

Check that the new rule exists

Connecting with the New Port

Run Remote Desktop Connection. You may do this by opening the Start Menu and typing "rdp" into the search bar. Select the option labeled "Remote Desktop Connection" with the words "Desktop app" below it.

(Note: The search bar in Windows 10 is not visible when the menu is first opened. To access the search bar, just start typing with the Start Menu open.)

Remote Desktop Connection from start menu

In the window that appears, enter the full hostname of the system being accessed, followed by a colon (:) and the new port number that you entered in Step 3. Hit "Connect" to finish.

(Note: Do not include spaces. A full hostname includes the domain names, ex: hostname.domain.domain.domain )

Enter full hostname with port number