Choose This PC > Properties > Advanced system settings > Advances > Environment Variables, add the variable OHOS_HDC_SERVER_PORT, and set its value to any port number not in use.
a. Start the terminal tool and run the echo $SHELL command. Based on the command output, run the following commands:
If the output is /bin/bash, run the vi ~/.bash_profile command to open the .bash_profile file.
If the output is /bin/zsh, run the vi ~/.zshrc command to open the .zshrc file.
b. Press i to enter Insert mode.
c. In the following content to add OHOS_HDC_SERVER_PORT information to PATH.
OHOS_HDC_SERVER_PORT= port number launchctl setenv OHOS_HDC_SERVER_PORT $OHOS_HDC_SERVER_PORT export OHOS_HDC_SERVER_PORT
d. Press Esc to exit the edit mode, and then input :wq and press Enter to save the settings and exit.
e. Run the following command for the environment variable to take effect.
If the .bash_profile file is opened in step 1, run the source ~/.bash_profile command.
If the .zshrc file is opened in step 1, run the source ~/.zshrc command.
f. Restart DevEco Studio.