如何在 Windows 中找到哪个程序正在使用端口 80?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1960750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I find which program is using port 80 in Windows?
提问by user198729
How do I find which program is using port 80 in Windows?
如何在 Windows 中找到哪个程序正在使用端口 80?
I can't find it.
我找不到。
回答by n0rd
Start menu → Accessories→ right click on "Command prompt". In the menu, click "Run as Administrator"(on Windows XP you can just run it as usual), run netstat -anb
, and then look through output for your program.
开始菜单 →附件→ 右键单击“命令提示符”。在菜单中,单击“以管理员身份运行”(在 Windows XP 上,您可以像往常一样运行它),运行netstat -anb
,然后查看程序的输出。
BTW, Skype by default tries to use ports 80 and 443 for incoming connections.
顺便说一句,Skype 默认尝试使用端口 80 和 443 进行传入连接。
You can also run netstat -anb >%USERPROFILE%\ports.txt
followed by start %USERPROFILE%\ports.txt
to open the port and process list in a text editor, where you can search for the information you want.
您还可以运行netstat -anb >%USERPROFILE%\ports.txt
后跟start %USERPROFILE%\ports.txt
在文本编辑器中打开端口和进程列表,您可以在其中搜索您想要的信息。
You can also use PowerShell to parse netstat
output and present it in a better way (or process it any way you want):
您还可以使用 PowerShell 来解析netstat
输出并以更好的方式呈现它(或以您想要的任何方式处理它):
$proc = @{};
Get-Process | ForEach-Object { $proc.Add($_.Id, $_) };
netstat -aon | Select-String "\s*([^\s]+)\s+([^\s]+):([^\s]+)\s+([^\s]+):([^\s]+)\s+([^\s]+)?\s+([^\s]+)" | ForEach-Object {
$g = $_.Matches[0].Groups;
New-Object PSObject |
Add-Member @{ Protocol = $g[1].Value } -PassThru |
Add-Member @{ LocalAddress = $g[2].Value } -PassThru |
Add-Member @{ LocalPort = [int]$g[3].Value } -PassThru |
Add-Member @{ RemoteAddress = $g[4].Value } -PassThru |
Add-Member @{ RemotePort = $g[5].Value } -PassThru |
Add-Member @{ State = $g[6].Value } -PassThru |
Add-Member @{ PID = [int]$g[7].Value } -PassThru |
Add-Member @{ Process = $proc[[int]$g[7].Value] } -PassThru;
#} | Format-Table Protocol,LocalAddress,LocalPort,RemoteAddress,RemotePort,State -GroupBy @{Name='Process';Expression={$p=$_.Process;@{$True=$p.ProcessName; $False=$p.MainModule.FileName}[$p.MainModule -eq $Null] + ' PID: ' + $p.Id}} -AutoSize
} | Sort-Object PID | Out-GridView
Also it does not require elevation to run.
它也不需要海拔来运行。
回答by Technotronic
Type in the command:
输入命令:
netstat -aon | findstr :80
It will show you all processes that use port 80. Notice the pid(process id) in the right column.
它将显示所有使用端口 80 的进程。注意右列中的pid(进程 ID)。
If you would like to free the port, go to Task Manager, sort by pidand close those processes.
如果您想释放端口,请转到Task Manager,按pid排序并关闭这些进程。
-adisplays all connections and listening ports.
- a显示所有连接和监听端口。
-odisplays the owning process ID associated with each connection.
- o显示与每个连接关联的拥有进程 ID。
-ndisplays addresses and port numbers in numerical form.
- n以数字形式显示地址和端口号。
回答by Manu
If you want to be really fancy, download TCPViewfrom Sysinternals:
如果你真的很喜欢,请从Sysinternals下载TCPView:
TCPView is a Windows program that will show you detailed listings of all TCP and UDP endpoints on your system, including the local and remote addresses and state of TCP connections. On Windows Server 2008, Vista, and XP, TCPView also reports the name of the process that owns the endpoint. TCPView provides a more informative and conveniently presented subset of the Netstat program that ships with Windows.
TCPView 是一个 Windows 程序,它将向您显示系统上所有 TCP 和 UDP 端点的详细列表,包括本地和远程地址以及 TCP 连接的状态。在 Windows Server 2008、Vista 和 XP 上,TCPView 还报告拥有端点的进程的名称。TCPView 提供了 Windows 附带的 Netstat 程序的更多信息和方便呈现的子集。
回答by Marcelo Mason
回答by Quang Trinh
Right click on "Command prompt" or "PowerShell", in menu click "Run as Administrator" (on Windows XP you can just run it as usual).
右键单击“命令提示符”或“PowerShell”,在菜单中单击“以管理员身份运行”(在 Windows XP 上,您可以像往常一样运行它)。
As Rick Vanover mentions in See what process is using a TCP port in Windows Server 2008
正如 Rick Vanover 在查看 Windows Server 2008 中使用 TCP 端口的进程中提到的那样
The following command will show what network traffic is in use at the port level:
Netstat -a -n -o
以下命令将显示端口级别正在使用的网络流量:
Netstat -a -n -o
or
或者
Netstat -a -n -o >%USERPROFILE%\ports.txt
(to open the port and process list in a text editor, where you can search for information you want)
(在文本编辑器中打开端口和进程列表,您可以在其中搜索您想要的信息)
Then,
然后,
with the PIDs listed in the netstat output, you can follow up with the Windows Task Manager (taskmgr.exe) or run a script with a specific PID that is using a port from the previous step. You can then use the "tasklist" command with the specific PID that corresponds to a port in question.
使用 netstat 输出中列出的 PID,您可以跟进 Windows 任务管理器 (taskmgr.exe) 或使用使用上一步中端口的特定 PID 运行脚本。然后,您可以将“tasklist”命令与与相关端口对应的特定 PID 一起使用。
Example:
例子:
tasklist /svc /FI "PID eq 1348"