|
| 1 | +--- |
| 2 | +title: Remote Desktop Can't Connect to the Remote Computer |
| 3 | +description: Helps resolve the Remote Desktop can't connect to the remote computer related errors. |
| 4 | +ms.date: 01/15/2025 |
| 5 | +manager: dcscontentpm |
| 6 | +audience: itpro |
| 7 | +ms.topic: troubleshooting |
| 8 | +ms.reviewer: kaushika, warrenw, franciscoang, v-lianna |
| 9 | +ms.custom: sap:Remote Desktop Services and Terminal Services\Session connectivity, csstroubleshoot |
| 10 | +--- |
| 11 | +# Remote Desktop can't connect to the remote computer |
| 12 | + |
| 13 | +This article helps troubleshoot errors when you connect to a remote machine. |
| 14 | + |
| 15 | +When you use a direct Remote Desktop Protocol (RDP) connection to connect to a Windows machine, the connection fails with one of the following errors. The error occurs before or after entering credentials on the Remote Desktop connection application. |
| 16 | + |
| 17 | +- > Remote Desktop can't connect to the remote computer for one of these reasons: |
| 18 | + > |
| 19 | + > 1\) Remote access to the server is not enabled |
| 20 | + > 2\) The remote computer is turned off |
| 21 | + > 3\) The remote computer is not available on the network |
| 22 | + > |
| 23 | + > Make sure the remote computer is turned on and connected to the network, and that remote access is enabled. |
| 24 | +
|
| 25 | +- > This computer can't connect to the remote computer. |
| 26 | + > |
| 27 | + > Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator. |
| 28 | +
|
| 29 | +There are several possible root causes, but the main ones are the RDP-TCP listener not working and incorrect network configurations. |
| 30 | + |
| 31 | +## Verify if the error is related to the machine's state or performance |
| 32 | + |
| 33 | +First, check if the machine is running. If it's running and has console access (for example, Integrated Lights Out (iLO) for physical machines, or Hyper-V console for virtual machines), test connecting to the machine through it. If successful, proceed to [verify if the error is related to the RDP-TCP listener](#verify-if-the-error-is-related-to-the-rdp-tcp-listener). |
| 34 | + |
| 35 | +Contact Microsoft Support for further assistance in the following scenarios: |
| 36 | + |
| 37 | +- You can't put the machine in a running state. |
| 38 | +- The machine is in a running state, but the console access to the machine fails. |
| 39 | + |
| 40 | +## Verify if the error is related to the RDP-TCP listener |
| 41 | + |
| 42 | +Run the `qwinsta` command to verify if the RDP-TCP listener is working for RDP connections to function. |
| 43 | + |
| 44 | +```console |
| 45 | +C:\Windows\System32>qwinsta |
| 46 | + SESSIONNAME USERNAME ID STATE TYPE DEVICE |
| 47 | + services 0 Disc |
| 48 | +>console 1 Active |
| 49 | + rdp-tcp 65536 Listen |
| 50 | +``` |
| 51 | + |
| 52 | +If the output list includes the `rdp-tcp` line in the `Listen` state, the RDP-TCP listener is running. Proceed to [verify if the error is related to the network](#verify-if-the-error-is-related-to-network). |
| 53 | + |
| 54 | +Otherwise, use the following methods to troubleshoot the issue. |
| 55 | + |
| 56 | +### Check registry configurations |
| 57 | + |
| 58 | +[!INCLUDE [Registry important alert](../../includes/registry-important-alert.md)] |
| 59 | + |
| 60 | +Open Registry Editor and make sure these keys are set as follows: |
| 61 | + |
| 62 | +- The DWORD value **fEnableWinStation** has the value data of **1**. |
| 63 | + |
| 64 | + Default path: |
| 65 | + `Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp` |
| 66 | + |
| 67 | +- The DWORD value **fDenyTSConnections** has the value data of **0**. |
| 68 | + |
| 69 | + - Default path: |
| 70 | + `Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server` |
| 71 | + - Policy path (if the policy is configured): |
| 72 | + `Computer\HKEY\_LOCAL\_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services` |
| 73 | + |
| 74 | +> [!NOTE] |
| 75 | +> Policies override default configurations and should be configured with **gpedit.msc** (locally) or **gpmc.msc** (domain level). |
| 76 | +> |
| 77 | +> If both policy and default value are configured, make sure both **fDenyTSConnections** values are set to **0**, to avoid possible listener issues. |
| 78 | +
|
| 79 | +### Check services |
| 80 | + |
| 81 | +Make sure the following services are running: |
| 82 | + |
| 83 | +- Remote Desktop Services (TermService). |
| 84 | +- Remote Desktop Services UserMode Port Redirector (UmRdpService). |
| 85 | + |
| 86 | +Contact Microsoft Support for further assistance if any of the services fails to start. |
| 87 | + |
| 88 | +### Check permissions |
| 89 | + |
| 90 | +Add the Network service to the local administrator group on the affected machine, and run the following PowerShell cmdlet on an elevated session: |
| 91 | + |
| 92 | +```powershell |
| 93 | +Add-LocalGroupMember -Group Administrators -Member "Network Service" |
| 94 | +``` |
| 95 | + |
| 96 | +After that, restart the Remote Desktop Services service (TermService). |
| 97 | + |
| 98 | +### Check sysprep state |
| 99 | + |
| 100 | +Make sure the machine isn't in Sysprep state by opening Registry Editor and checking the following keys: |
| 101 | + |
| 102 | +`Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\Setup` |
| 103 | + |
| 104 | +Both the DWORD values **SystemSetupInProgress** and **OOBEInProgress** are set to **0.** |
| 105 | + |
| 106 | +### Replace the RDP-TCP subkey |
| 107 | + |
| 108 | +Export the following subkey on a functioning machine with the same Windows version: |
| 109 | + |
| 110 | +`Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp` |
| 111 | + |
| 112 | +Back up the existing key on the affected machine. Then, delete it and replace it with the subkey exported from the functioning machine. |
| 113 | + |
| 114 | +> [!NOTE] |
| 115 | +> You can't access the machine via RDP with the `RDP-Tcp` subkey deleted. |
| 116 | +
|
| 117 | +### Contact Microsoft Support |
| 118 | + |
| 119 | +If the preceding steps can't resolve the issue of RDP-TCP listener not working, contact Microsoft Support for further assistance. |
| 120 | + |
| 121 | +## Verify if the error is related to network |
| 122 | + |
| 123 | +If the RDP-TCP listener is working, use the following steps to check if you can connect to the server through a console session (for example, iLO for physical machines, or Hyper-V console for virtual machines): |
| 124 | + |
| 125 | +1. Type **mstsc** in the **Run** box to open the **Remote Desktop Connection** application. |
| 126 | +2. In the **Remote Desktop Connection** application, type **localhost** in the **Computer** box and select **Connect**. |
| 127 | + |
| 128 | +If the error persists, the problem is with the server. Go to [verify machine's configurations and roles](#verify-machines-configurations-and-roles). |
| 129 | + |
| 130 | +If the error no longer occurs, it's probably related to the network and might be troubleshot further with the following steps. |
| 131 | + |
| 132 | +> [!NOTE] |
| 133 | +> The preceding test is only possible on Windows Server machines and might not be available on all occasions (for example, Azure virtual machines). |
| 134 | +> |
| 135 | +> If it isn't available or possible, test connectivity with the [Test-NetConnection](/powershell/module/nettcpip/test-netconnection) cmdlet from a machine in the same network. |
| 136 | +
|
| 137 | +To confirm connectivity issues, run the following steps from a machine in the same network: |
| 138 | + |
| 139 | +1. Open an elevated PowerShell window, and run the following cmdlet: |
| 140 | + |
| 141 | + ```PowerShell |
| 142 | + Test-NetConnection -ComputerName <www.contoso.com> -port 3389 -InformationLevel Detailed |
| 143 | + ``` |
| 144 | +
|
| 145 | +2. In the output list, if `TcpTestSucceeded` is `True`, it indicates no connectivity issues. Go to [verify machine's configurations and roles](#verify-machines-configurations-and-roles). |
| 146 | +3. If `TcpTestSucceeded` is `False`, it indicates connectivity issues. Go to the next step. |
| 147 | +
|
| 148 | +### Check the default RDP port |
| 149 | +
|
| 150 | +Open Registry Editor and make sure the following key is set as follows: |
| 151 | +
|
| 152 | +`Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp` |
| 153 | +
|
| 154 | +The DWORD value **PortNumber** has the value **0x00000d3d (3389)**. |
| 155 | +
|
| 156 | +If the value is different, **Remote Desktop Connection** connections should use *hostname*:*port* or *IPaddress*:*port* as the computer name. |
| 157 | +
|
| 158 | +### Check Domain Name System (DNS) resolution |
| 159 | +
|
| 160 | +If the connection fails when using the machine's hostname, try connecting using its IP address. |
| 161 | +
|
| 162 | +- If the connection works with the IP address, the issue is likely related to name resolution. |
| 163 | +- If the connection also fails with the IP address, proceed to the next troubleshooting step. |
| 164 | +
|
| 165 | +### Check Firewall or Network Security Group configuration |
| 166 | +
|
| 167 | +Check if firewall rules allow RDP to the machine, or if the firewall is disabled. |
| 168 | +
|
| 169 | +Open **wf.msc**, select **Inbound Rules** and look for **Remote Desktop - User Mode (TCP-In)** and **Remote Desktop - User Mode (UDP-In)**. Make sure that they're enabled to all profiles. |
| 170 | +
|
| 171 | +You can get the same result with the following PowerShell cmdlet on an elevated session: |
| 172 | +
|
| 173 | +```powershell |
| 174 | +Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Set-NetFirewallRule -Enabled True |
| 175 | +``` |
| 176 | + |
| 177 | +To rule out the firewall, it can be disabled with the PowerShell cmdlet: |
| 178 | + |
| 179 | +```powershell |
| 180 | +Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False |
| 181 | +``` |
| 182 | + |
| 183 | +If other network elements are restricting traffic, they should be checked. |
| 184 | + |
| 185 | +When using Azure Cloud, check if the Network Security Group (NSG) is configured to allow RDP to a subnet or network interface card (NIC). NSG is mandatory if you use [standard SKU for public IP addresses](/azure/virtual-network/ip-services/public-ip-addresses#sku). |
| 186 | + |
| 187 | +### Check Anti-Virus (AV) |
| 188 | + |
| 189 | +Anti-virus can negatively affect RDP connections to machines. If possible, disable the AV service and test the connections. |
| 190 | + |
| 191 | +To completely rule out the AV as the root cause, uninstall it and restart the machine. |
| 192 | + |
| 193 | +### Contact Microsoft Support |
| 194 | + |
| 195 | +If the preceding steps can't resolve the issue, the RDP-TCP listener is working and the connectivity test result is `False`, contact Microsoft Support for further assistance. |
| 196 | + |
| 197 | +## Verify machine's configurations and roles |
| 198 | + |
| 199 | +If the RDP-TCP listener is working, and the connectivity test result to the machine is `True`, other scenarios related to machine's processes, roles or configurations should be checked. |
| 200 | + |
| 201 | +### Check the concurrent process using the default RDP port |
| 202 | + |
| 203 | +Run the following commands in an elevated command prompt or PowerShell window, and make sure the Process ID (PID) of `TermService` matches the one listening on port 3389: |
| 204 | + |
| 205 | +- ```console |
| 206 | + tasklist /svc | findstr TermService |
| 207 | + ``` |
| 208 | + |
| 209 | +- ```console |
| 210 | + netstat -anob | findstr 3389 |
| 211 | + ``` |
| 212 | + |
| 213 | +For example, `TermService` with PID 820 is listening on port 3389. |
| 214 | + |
| 215 | +```console |
| 216 | +C:\Windows\System32>tasklist /svc | findstr TermService |
| 217 | +svchost.exe 820 TermService |
| 218 | + |
| 219 | +C:\Windows\System32>netstat -anob | findstr 3389 |
| 220 | + TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 820 |
| 221 | + TCP [::]:3389 [::]:0 LISTENING 820 |
| 222 | + UDP 0.0.0.0:3389 *:* 820 |
| 223 | + UDP [::]:3389 *:* 820 |
| 224 | +``` |
| 225 | + |
| 226 | +If the PID doesn't match, find what process is listening on port 3389 and stop it. Then, restart the Remote Desktop Services service (TermService). |
| 227 | + |
| 228 | +### Check Remote Desktop self-signed certificate |
| 229 | + |
| 230 | +Check if you can re-create the Remote Desktop self-signed certificate by following these steps: |
| 231 | + |
| 232 | +1. Open the Certificates Microsoft Management Console (MMC) snap-in. When you're prompted to select the certificate store to manage, select **Computer account**, and then select the affected computer. |
| 233 | +2. In the **Certificates** folder under **Remote Desktop**, delete the RDP self-signed certificate. |
| 234 | +3. Restart the Remote Desktop Services service on the affected computer. |
| 235 | +4. Refresh the **Certificates** snap-in. |
| 236 | +5. If the RDP self-signed certificate isn't re-created, go to [Remote Desktop self-signed certificate](internal-error-has-occurred-connecting-remote-machine.md#remote-desktop-self-signed-certificate). |
| 237 | +6. If the RDP self-signed certificate is re-created, go to the next step. |
| 238 | + |
| 239 | +### Check Remote Desktop Services (RDS) roles |
| 240 | + |
| 241 | +Check if unnecessary RDS roles are installed, on **Server Manager** > **Manage** > **Remove Roles and Features** > **Server Roles** - **Remote Desktop Services**. |
| 242 | + |
| 243 | +If unnecessary roles are installed, uncheck the corresponding box and proceed to remove them (for example, Remote Desktop Connection Broker role). Restart the machine in the end. |
| 244 | + |
| 245 | +Machines with the Remote Desktop Connection Broker role in RDS deployments might still encounter the issue if the following conditions aren't met: |
| 246 | + |
| 247 | +- Check if the Remote Desktop Connection Broker service (TSSDis) is running. |
| 248 | +- In the Computer Management (**compmgmt.msc**) snap-in, **System Tools** > **Local Users and Groups** > **Groups** > **RDS Endpoint Servers** group must contain the **NT AUTHORITY\NETWORK SERVICE** account. |
| 249 | + |
| 250 | +### **Contact Microsoft Support** |
| 251 | + |
| 252 | +If the preceding steps can't resolve the issue, the RDP-TCP listener is working and the connectivity test result is `True`, contact Microsoft Support for further assistance. |
0 commit comments