如何在Windows中使用localhost上的端口杀死当前进程? [英] How do I kill the process currently using a port on localhost in Windows?

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

问题描述

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

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

例如:localhost:8080

推荐答案

步骤1:

打开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 :PORT_NUMBER

(用所需的端口号替换PORT_NUMBER,但保留冒号)

(Replace PORT_NUMBER 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 PORT_NUMBER /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中使用localhost上的端口杀死当前进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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