开启某软件时提示错误
An attempt was made to access a socket in a way forbidden by its access permissions
netstat -aon|findstr "被占用端口号"
返回如下
TCP 127.0.0.1:9809 0.0.0.0:0 LISTENING 11924
*最后一个数字是该程序PID
taskkill /pid 该程序PID -t -f
*适用于netstat无返回的情况
可能是Windows的Hyper-V虚拟机保留了该端口。
可通过如下命令查看
netsh interface ipv4 show excludedportrange protocol=tcp
将返回被保留的端口,如
协议 tcp 端口排除范围
开始端口 结束端口
---------- --------
1131 1230
9001 9001
50000 50059 *
* - 管理的端口排除。
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
netsh int ipv4 add excludedportrange protocol=tcp startport=50051 numberofports=1
reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
原文:https://www.cnblogs.com/StarsbySea/p/Windows-ports-occupied.html