All Products
Search
Document Center

:What do I do if port conflicts occur when I connect to a Windows ECS instance?

Last Updated:Mar 20, 2025

This topic describes how to resolve the issue that you cannot connect to a Windows Elastic Compute Service (ECS) instance because of port conflicts.

Problem description

When you connect to a Windows ECS instance by using the built-in Microsoft Terminal Services Client (MSTSC) tool on your on-premises device that runs a Windows operating system or by using Workbench in the ECS console, an error message indicating that the session is disconnected appears. As a result, you cannot connect to the Windows ECS instance. The following figure shows a sample error message for MSTSC.端口冲突

Cause

The Remote Desktop Protocol (RDP) port of the Windows operating system is used by another process or service. The default RDP port is 3389.

Solutions

You can terminate the process that uses the RDP port or change the RDP port number. Perform the following steps.

Important
  • Before you perform high-risk operations such as modifying the configurations or data of an Alibaba Cloud instance, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security. For information about snapshots, see Overview.

  • If you granted access permissions on or submitted sensitive information (such as usernames and passwords) in the Alibaba Cloud Management Console, we recommend that you modify the information at the earliest opportunity.

  1. Connect to the Windows ECS instance by using Virtual Network Computing (VNC).

    For more information, see the Windows instance section of the "Connect to an instance by using VNC" topic.

  2. View the process that uses the RDP port. In this example, Windows Server 2022 is used.

    1. Open the Command Prompt window.

    2. In the Command Prompt window, run the netstat -ano|findstr "3389" command to identify the process that uses port 3389.

      查看端口占用进程

    3. Run the tasklist /FI "PID eq <PID that you obtained in the previous step>" command to view the process details. Replace the PID of the process to be terminated with the actual PID. In this example, the tasklist /FI "PID eq 4176" and tasklist /FI "PID eq 7164" commands are run. In the command output, svchost.exe is the RDP process, and python.exe is the process that uses port 3389.image

  3. Method 1: Terminate the process that uses port 3389.

    1. Run the taskkill /PID <PID of the process to be terminated> /F command. Replace the PID of the process to be terminated with the actual PID. In this example, the taskkill /PID 4176 /F command is run.

      Important

      To prevent impacts on your business, we recommend that you fully understand the features of a process before you terminate the process. Stopping a key business or system process may cause a business interruption, a system crash, or an instance connection failure.

    2. Use MSTSC or Workbench to reconnect to the Windows ECS instance.

  4. Method 2: Change the RDP port number.

    1. Open Registry Editor.

      注册表编辑器

    2. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp path and right-click the PortNumber parameter. In the dialog box that appears, change the Value data value to the port number that you want to use.tcp修改PortNumber

    3. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp path and right-click the PortNumber parameter. In the dialog box that appears, change the Value data value to the port number that you want to use.

      Note

      You must specify the same Value data value for the PortNumber parameter of the tcp and RDP-Tcp registry keys.

      RDP-Tcp修改PortNumberThe Windows operating system automatically recognizes the new RDP port number.

    4. Open the Services window.

    5. Right-click Remote Desktop Services and then select Restart.重启RDP服务

    6. Configure security group rules to allow traffic on the new RDP port.

      For information about how to add a security group rule, see Add a security group rule.

    7. Use MSTSC or Workbench to reconnect to the Windows ECS instance.