Kill a process in Windows by Port Number

 

While working with Angular projects, a lot of times I forget to kill the running NPM process before closing the command line tool. And then when I want to run the app on same port again it throws me an error that the port is used by some other process. Now, this is just an example, but it is quite possible that this might have happened with you as well while working on some web project. In case you are scratching your head for which command to use to kill the process just by knowing the port number, here is the post that might help you. Well I know this is not that great a problem, but sometimes we spend hours solving the dumbest problems. Smile

So first you need to find the PID of your process that is running on that specific port. Here is the command that gives you list of all process with port numbers. Shoot this command in command prompt. 

“netstat -a -o –n”

It will show you a similar output -

image

Now type Ctl + F to find the port that you are looking for. For me, it was 4200. Note the PID of this process in the last column. For me it was 15508

image

 

Now simply use the command to kill the process by PID -

“taskkill /F /PID 15508”

Make sure to change the PID to your own PID. And that is it. You can run the new process on same port now.


Posted Oct 18 2017, 11:20 AM by Indraneel Pole
developers.de is a .Net Community Blog powered by daenet GmbH.