目录

What should I do if "Hdc server port XXXX has been used" is displayed during running the HAP?

Symptom

When the HAP is running in the device, the error message "Hdc server port XXXX has been used. Configure environment variable 'OHOS_HDC_SERVER_PORT' and restart DevEco Studio." is displayed.

Solution

This issue occurs because the default HDC port (8710) is being used by another process, preventing the service from starting. To resolve this issue:

Method 1: Stop the application that occupies the port.

  1. Run the command line tool and enter netstat -ano | findstr Port number to query the process ID (PID) that occupies the port number.

  2. Open Task Manager, click the Details tab, and locate the application based on the PID.

  3. Stop the application and restart DevEco Studio.

Method 2: Set other environment variables for the hdc port number.

Method 3: If the port is not occupied, check whether the port is blocked by the firewall. If it is, unblock the port and then restart DevEco Studio to try again.