How do I kill the process currently using a port on localhost in Windows?

后端 未结 20 2300
陌清茗
陌清茗 2020-11-22 11:37

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

For example: localhost:8080

20条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 12:23

    Here is a script to do it in WSL2

    PIDS=$(cmd.exe /c netstat -ano | cmd.exe /c findstr :$1 | awk '{print $5}')
    for pid in $PIDS
    do
        cmd.exe /c taskkill /PID $pid /F
    done
    

提交回复
热议问题