首页/网络/网络排障速查/netstat -ano 定位 Windows 端口占用
本包目录(235 条)

netstat -ano 定位 Windows 端口占用

Windows 端查端口与 PID 的主力命令:-a 全部、-n 数字、-o 显示 PID,再用 tasklist 或 Get-Process 把 PID 翻译成进程;Get-NetTCPConnection 更现代。

网络排障速查网络更新于 2026-10-12

PowerShell / CMD

PowerShell / CMD
netstat -ano | Select-String ':8080'
netstat -ano | findstr LISTENING | findstr ':80 '
# PID → 进程:
tasklist /FI "PID eq 12345"
Get-Process -Id 12345 | Select-Object ProcessName, Path
Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalAddress, State, OwningProcess
场景Windows 端口冲突 / 可疑监听排查
工具netstat -ano、Get-NetTCPConnection、tasklist
要点PID 在输出行最右侧;监听状态显示为 LISTENING
Windows 的 netstat 字段与 Linux 不同:Local Address 0.0.0.0:80 表示所有网卡,127.0.0.1:80 仅本机。

易错点

  • 拿到 PID 直接结束进程:先确认是系统托管服务(svchost)还是业务进程
  • findstr ':80' 会同时匹配 8080、8000,需要加空格界定

数据来源与参考

  • Microsoft Learn:netstat 命令参考
  • Microsoft Learn:Get-NetTCPConnection

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌