remotedesk.in Menu

Remote Desktop port: 3389, and how to change it

Remote Desktop allows remote connections to computers running Windows or Windows Server over the Remote Desktop Protocol (RDP), listening on port 3389 by default. source

Where is the port set?

The listening port for Remote Desktop is specified in the registry.

Open PowerShell as an administrator.

In Microsoft’s words: Microsoft Learn, Change the Remote Desktop listening port

The command that reads it:

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

From Microsoft Learn, Change the Remote Desktop listening port

How do I change it?

Microsoft’s two lines, with your number in place of <Port Number>:

$portValue = '<Port Number>'
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'PortNumber' -Value $portValue

From Microsoft Learn, Change the Remote Desktop listening port

Does the firewall need a rule?

If you use the Windows Firewall, you need to add a new inbound rule to allow traffic on the new port.

In Microsoft’s words: Microsoft Learn, Change the Remote Desktop listening port
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile Public -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portValue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile Public -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portValue

From Microsoft Learn, Change the Remote Desktop listening port

If you're using a different firewall, make sure the port for Remote Desktop (usually 3389) is open.

In Microsoft’s words: Microsoft Learn, Remote PC connections FAQ

How do I connect after changing it?

The next time you connect to this computer by using the Remote Desktop Connection or other client, enter the hostname along with the new port. For example, if you changed the port to use 3390 on computer pc1.contoso.com, the address is pc1.contoso.com:3390.

In Microsoft’s words: Microsoft Learn, Change the Remote Desktop listening port

Should 3389 be open to the internet?

Typically, the port is 3389 - that's the default port used by Remote Desktop connections.

You're opening your PC up to the internet, which isn't recommended. If you must, make sure you have a strong password set for your PC. It's preferable to use a VPN.

If you connect to your local area network by using a virtual private network (VPN), you don't have to open your PC to the public internet.

Dynamic DNS (DDNS) lets you connect to the PC using an easy to remember domain name, instead of the IP address.

In Microsoft’s words: Microsoft Learn, Allow access to your PC from outside its network