我试图为我的应用服务器使用端口80,但当我执行netstat -aon时,我得到:
TCP 0.0.0.0:80 0.0.0.0:0监听4
当我在任务管理器中查找进程时,它显示PID 4是SYSTEM,就是这样。没有扩展…什么都没有。“系统”。这是怎么回事?
我害怕结束这个过程,我该怎么办?
我试图为我的应用服务器使用端口80,但当我执行netstat -aon时,我得到:
TCP 0.0.0.0:80 0.0.0.0:0监听4
当我在任务管理器中查找进程时,它显示PID 4是SYSTEM,就是这样。没有扩展…什么都没有。“系统”。这是怎么回事?
我害怕结束这个过程,我该怎么办?
当前回答
在windows的最新版本中,这项服务被称为“万维网发布服务”(W3SVC)。
C:\Windows\system32\svchost.exe -k iissvcs
您可以通过进入Services (Services .msc)并停止该服务,然后设置“启动类型”—>禁用,以防止它在windows启动时运行。
其他回答
此外,“开发人员门户”(在Windows 10上)会导致系统在TCP端口上侦听。通常为50080和50443端口。
一个名为“Web部署代理服务”(MsDepSvc)的新服务也可以触发PID=4的“系统”在80端口上监听。
对我来说,我必须在我的虚拟机上卸载“Citrix虚拟桌面代理”
以下五个步骤可以很容易地解决这个问题:
开放服务 右击万维网出版服务 点击停止
为防止此类问题再次发生:
转到属性 修改“启动类型”为“手动”
维奥拉准备好了!
有关根本原因的更多信息:https://serverfault.com/questions/65717/port-80-is-being-used-by-system-pid-4-what-is-that
以编程方式标识流程
到目前为止,所有的答案都要求用户进行一些交互操作。这就是当netstat显示PID 4时如何找到PID,而不需要打开一些GUI或处理有关依赖服务的对话。
$Uri = "http://127.0.0.1:8989" # for example
# Shows processes that have registered URLs with HTTP.sys
$QueueText = netsh http show servicestate view=requestq verbose=yes | Out-String
# Break into text chunks; discard the header
$Queues = $QueueText -split '(?<=\n)(?=Request queue name)' | Select-Object -Skip 1
# Find the chunk for the request queue listening on your URI
$Queue = @($Queues) -match [regex]::Escape($Uri -replace '/$')
if ($Queue.Count -eq 1)
{
# Will be null if could not pick out exactly one PID
$ProcessId = [string]$Queue -replace '(?s).*Process IDs:\s+' -replace '(?s)\s.*' -as [int]
if ($ProcessId)
{
Write-Verbose "Identified process $ProcessId as the HTTP listener. Killing..."
Stop-Process -Id $ProcessId -Confirm
}
}
那可真让我受不了。我讨厌HttpListener,希望我只使用Pode。