我试图为我的应用服务器使用端口80,但当我执行netstat -aon时,我得到:

TCP 0.0.0.0:80 0.0.0.0:0监听4

当我在任务管理器中查找进程时,它显示PID 4是SYSTEM,就是这样。没有扩展…什么都没有。“系统”。这是怎么回事?

我害怕结束这个过程,我该怎么办?


当前回答

一个名为“Web部署代理服务”(MsDepSvc)的新服务也可以触发PID=4的“系统”在80端口上监听。

其他回答

另外,尝试停止“SQL Server Reporting Services (MSSQLSERVER)”,显然默认值是80。我这样做了,端口80释放了。PID认为罪魁祸首是“系统”,但显然这个系统可以有多种含义。

这对我来说很管用:

右键单击我的电脑。 选择管理。 双击“服务和应用程序”。 然后双击Services。 右击“万维网出版服务”。 选择停止。

在windows的最新版本中,这项服务被称为“万维网发布服务”(W3SVC)。

C:\Windows\system32\svchost.exe -k iissvcs

您可以通过进入Services (Services .msc)并停止该服务,然后设置“启动类型”—>禁用,以防止它在windows启动时运行。

尝试netstat -b,这可能会对情况有所帮助(显示什么.exe正在使用端口)。祝你好运。

以编程方式标识流程

到目前为止,所有的答案都要求用户进行一些交互操作。这就是当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。