Windows - Kill process by port

author: Paul Kim

categories: windows

tags: windows

There have been times when I needed to kill the process running Kestrel HTTP server while working on ASP.NET Core web applications. In this short post, I will go over how I was able to do that from the Command Prompt on Windows.


Basically, we need to find the process that the port is running on. For instance, suppose we want to find the process that port 5000 is running on. We use netstat -ano -p TCP | find /I "listening" | find /I "5000" command to find the process running TCP protocol listening on port 5000. Once we figure out the process number is 19948 in this particular case, we use taskkill /F /PID 19948 command to forcefully terminate the process.

C:\Users\Paul>netstat -ano -p TCP | find /I "listening" | find /I "5000"
TCP              LISTENING       19948

C:\Users\Paul>taskkill /F /PID 19948


© 2021 All rights reserved.