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

TCP 0.0.0.0:80 0.0.0.0:0监听4

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

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


当前回答

如果您使用雷蛇产品并在PC上安装雷蛇Synapse软件,它也会阻塞端口80。

它不包括在netstat命令中,因此我无法排除故障。由于软件中包含了许多服务,所以我无法分析是哪个服务阻塞了端口。卸载Razer Synapse后,我可以在Windows 10上重新启动Apache服务器。

其他回答

我也有同样的问题。可以通过停止正在运行的服务下的万维网发布服务来修复它。

这不能解释PID方面的事情,但如果你运行Skype,它喜欢使用端口80出于某种原因。

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

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

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

以编程方式标识流程

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

问题是如何释放它,简单地使用

net stop http

https://stackoverflow.com/a/16243333/777982