Reference · Remote access
Remote Desktop port 3389: check whether it is on and reachable from the internet
Check whether Windows Remote Desktop listens on port 3389 (or a changed port), whether the internet can reach it through a router port forward or public IP, and how to turn it off or put it behind a VPN with Network Level Authentication.
| Target artifact | The Windows Remote Desktop service, listening on TCP port 3389 unless the PortNumber value under HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp changes it. |
|---|---|
| Default behaviour | Off. Pro, Enterprise and Education editions can accept Remote Desktop connections once it is turned on; Home editions cannot. A router port forward or a public address then puts the port on the internet, where attackers search for it and guess passwords without any user noticing. |
| Safe state | Off on computers nobody connects to. Where it is needed: reachable only through a VPN, Network Level Authentication on, strong unique passwords, account lockout and sign-in logging on, and no port forward from the internet. |
| Check on Windows | Get-NetTCPConnection -State Listen -LocalPort 3389 -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, OwningProcess |
| Check from another device | Test-NetConnection -ComputerName PUBLIC_IP -Port 3389 in PowerShell, from a network outside yours |
| Fix on Windows | Settings, System, Remote Desktop, then turn Remote Desktop off |
| Fix at the router | delete any port forward to port 3389, or to the changed port |
Read the result
- No output: nothing listens on 3389. Check that nobody moved Remote Desktop to another port, below.
0.0.0.0or::on the port: Remote Desktop is on and listening on every interface. Whether the internet can reach it depends on the router and firewall; test from outside.TcpTestSucceeded : Truefrom another network: the port is reachable from the internet. Turn Remote Desktop off or close the port forward now, then check the sign-in log below.
The port number is stored in the registry. Read it, and repeat the check with that number if it is not 3389:
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber'A changed port is still found by scanners; it is not a defence.
Why it matters
The FBI warns that criminals find exposed Remote Desktop sessions over the internet and use them to steal credentials and hold data for ransom, and that these attacks need no action from the user, which makes them hard to notice. CISA's ransomware guide puts it plainly: do not expose services such as Remote Desktop on the web, and audit the network for systems using it.
Turn it off, or put it behind a VPN
Turn Remote Desktop off
- Open Settings, then System, then Remote Desktop.
- Turn Remote Desktop off.
- Run the check again; it should print nothing.
To block it in the firewall as well, disable Windows' built-in Remote Desktop rules. On Windows installed in another language, the group name is translated:
Get-NetFirewallRule -DisplayGroup 'Remote Desktop' | Select-Object DisplayName, Enabled, Profile
Disable-NetFirewallRule -DisplayGroup 'Remote Desktop'If you need it from outside
- Connect through a VPN to your network first, and connect to the computer's local address. Remove any router port forward to it.
- Keep Network Level Authentication on, so users must authenticate before a session is set up. Microsoft recommends it for most environments.
- Give every account that can connect a strong, unique password, and set an account lockout policy against password guessing.
- Members of the Administrators group can connect once Remote Desktop is on; review who else is allowed in the same Settings page.
Read who connected
CISA suggests reviewing the TerminalServices-RemoteConnectionManager log for successful connections:
Get-WinEvent -LogName 'Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational' -MaxEvents 50 | Select-Object TimeCreated, Id, MessageIf you see connections you cannot explain, treat the computer as compromised: disconnect it, and change passwords from another device.
Cloud servers
A cloud Windows server with a public address should not have port 3389 open to the internet unless there is a business reason, according to the FBI. Restrict it in the provider's network security rules to your VPN or office address, or reach the server through the provider's own console or bastion service.
Related guides and lookups
Sources
- Microsoft Learn: change the Remote Desktop listening port
- Microsoft Learn: enable Remote Desktop on your PC
- Microsoft Support: how to use Remote Desktop
- Microsoft Learn: fDenyTSConnections
- Microsoft Learn: Test-NetConnection
- FBI: cyber actors increasingly exploit Remote Desktop Protocol, 27 September 2018
- CISA: #StopRansomware guide