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

例如:localhost:8080


当前回答

最简单的解决办法,也是我唯一记得的办法:

在Windows Powershell中

假设我们想停止端口8080上的进程

获取过程:

netstat -ano | findstr :8080

停止进程

stop-process 82932

其他回答

用于命令行:

for /f "tokens=5" %a in ('netstat -aon ^| find ":8080" ^| find "LISTENING"') do taskkill /f /pid %a

用于蝙蝠档案:

for /f "tokens=5" %%a in ('netstat -aon ^| find ":8080" ^| find "LISTENING"') do taskkill /f /pid %%a

最简单的解决办法,也是我唯一记得的办法:

在Windows Powershell中

假设我们想停止端口8080上的进程

获取过程:

netstat -ano | findstr :8080

停止进程

stop-process 82932

我在Windows上运行zookeeper,无法使用zookeeper-stop.sh停止在2181端口运行的zookeeper,所以尝试了这个双斜线“//”方法来kill任务。它工作

     1. netstat -ano | findstr :2181
       TCP    0.0.0.0:2181           0.0.0.0:0              LISTENING       8876
       TCP    [::]:2181              [::]:0                 LISTENING       8876

     2.taskkill //PID 8876 //F
       SUCCESS: The process with PID 8876 has been terminated.

以管理员身份运行cmd。然后在里面输入这个代码。

netstat -ano | findstr :<8080>

然后您可以看到PID在端口上运行。然后复制PID编号。(PID是帮助识别硬件产品或已注册软件产品的唯一数字。)并键入下面的代码行和按enter。

taskkill /PID <Enter the copied PID Number> /F

第一步

netstat -vanp tcp | grep 8888

例子

tcp4     0      0    127.0.0.1.8888   *.*    LISTEN      131072 131072  76061    0
tcp46    0      0    *.8888           *.*    LISTEN      131072 131072  50523    0

第二步:找到你的pid并杀死他们

对我来说

sudo kill -9 76061 50523