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

后端 未结 20 2070
陌清茗
陌清茗 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条回答
  •  名媛妹妹
    2020-11-22 12:26

    If you're using Windows Terminal then the killing process might be little less tedious. I've been using windows terminal and kill PID works fine for me to kill processes on the port as the new Windows Terminal supports certain bash commands. For example: kill 13300

    So, the complete process will look like this-

    • Open Windows Terminal
    • Type the following command to show processes running on the port you're looking to kill processes. netstat -ano | findstr :PORT
    • Type following to kill the process. kill PID

    For Example:

    PS C:\Users\username> netstat -ano | findstr :4445
      TCP    0.0.0.0:4445           0.0.0.0:0              LISTENING       7368
      TCP    [::]:4445              [::]:0                 LISTENING       7368
    PS C:\Users\username> kill 7368
    PS C:\Users\username> netstat -ano | findstr :4445
    PS C:\Users\username>
    

    See when I typed the first command to list processes on the port it returned empty. That means all processes are killed now.

提交回复
热议问题