1 查看端口占用

netstat -aon|findstr “被占用端口号”
taskkill /pid 该程序PID -t -f

2 查看被占用的端口范围

netsh interface ipv4 show excludedportrange protocol=tcp

3 解决办法:

Hyper-V的动态端口保留​(默认保留端口范围:5000-65535)

1
2
3
4
5
6
7
8
# 1. 临时禁用Hyper-V(需重启)
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

# 2. 重启后保留目标端口
netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=1

# 3. 重新启用Hyper-V(需重启)
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

4 参考

删除30000-40000的TCP端口保留范围

1
2
netsh int ipv4 delete excludedportrange protocol=tcp startport=30000 numberofports=10001
netsh interface ipv4 show excludedportrange protocol=tcp