如何终止当前在 Windows 本地主机上使用端口的进程? [英] How do I kill the process currently using a port on localhost in Windows?

查看:19
本文介绍了如何终止当前在 Windows 本地主机上使用端口的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除已分配给端口的当前进程/应用程序?

How can I remove the current process/application which is already assigned to a port?

例如:localhost:8080

推荐答案

第一步:

打开 cmd.exe(注意:您可能需要以管理员身份运行它,但这并不总是必要的),然后运行以下命令:

Open up cmd.exe (note: you may need to run it as an administrator, but this isn't always necessary), then run the below command:

netstat -ano |findstr :<端口>

(将 替换为您想要的端口号,但保留冒号)

(Replace <PORT> with the port number you want, but keep the colon)

红色圆圈区域表示PID(进程标识符).找到正在使用所需端口的进程的 PID.

The area circled in red shows the PID (process identifier). Locate the PID of the process that's using the port you want.

第 2 步:

接下来,运行以下命令:

Next, run the following command:

taskkill/PID ;/F

(这次没有冒号)

最后,您可以通过重新运行步骤 1"中的命令来检查操作是否成功.如果成功,您将不会再看到该端口号的任何搜索结果.

Lastly, you can check whether the operation succeeded or not by re-running the command in "Step 1". If it was successful you shouldn't see any more search results for that port number.

这篇关于如何终止当前在 Windows 本地主机上使用端口的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆