Notes

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.

Overview

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    127.0.0.1:5000         0.0.0.0:0              LISTENING       19948

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

ChromeEdgeFirefoxOpera

© 2021 paulkode.com. All rights reserved.