如何确定哪个进程正在使用 Windows 上的端口 18780?
How can I identify which process is using port 18780 on Windows?
我有一个内部 Web 应用程序侦听端口 18780 上的所有 IP。当我尝试在新的 Windows VM 上启动该应用程序时,它抛出此异常:
System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:18780
重新启动机器后,应用程序启动得很好,但我想避免在使用它们之前必须重新启动所有新的 QA 环境。
IANA reports that nothing well-known uses port 18780.
上次发生这种情况时,我试图确定那个端口上的 运行 进程是什么:
运行 Get-Process -Id (Get-NetTCPConnection -LocalPort 18780).OwningProcess
返回 Cannot find a process with the process identifier 7188
。 Powershell 在本地管理员帐户下 运行。
那么这里发生了什么?看起来好像有什么东西在使用那个端口,它有一个进程 ID,但我无法获得它的详细信息。 运行 这个 powershell 命令第二次报告说没有任何东西在监听那个端口。观察行为会改变 Windows 过程吗?
我可以采取哪些进一步的步骤来了解有关薛定谔过程的更多信息?
尝试在 powershell 中执行以下操作:
netstat -ano | findstr :<port>
这将为您提供有关进程 ID 的详细信息
然后使用以下方法终止进程:
taskkill /PID <processid> /F
再次发现这种情况。
事实证明,我的应用程序生成了三个子进程,而且它们仍然是 运行。 Windows 显然在清理拥有进程 record 之前不会释放 TCP 端口,并且子进程维护此记录。即使父进程已停止,并在 TCPViewer 中显示为 <non-existent>
,端口仍然不可用。
此处也有描述:https://serverfault.com/questions/181015/how-do-you-free-up-a-port-being-held-open-by-dead-process
我使用 wmic process where (ParentProcessId=7188) get Caption,ProcessId
来确定要杀死哪些子进程,这就成功了。 Windows直接释放端口
我有一个内部 Web 应用程序侦听端口 18780 上的所有 IP。当我尝试在新的 Windows VM 上启动该应用程序时,它抛出此异常:
System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:18780
重新启动机器后,应用程序启动得很好,但我想避免在使用它们之前必须重新启动所有新的 QA 环境。
IANA reports that nothing well-known uses port 18780.
上次发生这种情况时,我试图确定那个端口上的 运行 进程是什么:
运行 Get-Process -Id (Get-NetTCPConnection -LocalPort 18780).OwningProcess
返回 Cannot find a process with the process identifier 7188
。 Powershell 在本地管理员帐户下 运行。
那么这里发生了什么?看起来好像有什么东西在使用那个端口,它有一个进程 ID,但我无法获得它的详细信息。 运行 这个 powershell 命令第二次报告说没有任何东西在监听那个端口。观察行为会改变 Windows 过程吗?
我可以采取哪些进一步的步骤来了解有关薛定谔过程的更多信息?
尝试在 powershell 中执行以下操作:
netstat -ano | findstr :<port>
这将为您提供有关进程 ID 的详细信息
然后使用以下方法终止进程:
taskkill /PID <processid> /F
再次发现这种情况。
事实证明,我的应用程序生成了三个子进程,而且它们仍然是 运行。 Windows 显然在清理拥有进程 record 之前不会释放 TCP 端口,并且子进程维护此记录。即使父进程已停止,并在 TCPViewer 中显示为 <non-existent>
,端口仍然不可用。
此处也有描述:https://serverfault.com/questions/181015/how-do-you-free-up-a-port-being-held-open-by-dead-process
我使用 wmic process where (ParentProcessId=7188) get Caption,ProcessId
来确定要杀死哪些子进程,这就成功了。 Windows直接释放端口