Let's Automate!
If you fall into this issue much often like me, make an .bat file and run it to end process.
create a bat file "killport.bat"
set /P port="Enter port : "
echo showing process running with port %port%
netstat -ano|findstr "PID :%port%"
set /P pid="Enter PID to kill : "
taskkill /pid %pid% /f
set /P exit="Press any key to exit..."
Run this file by double clicking and
- Enter port number (then it will list process with PID)
- Enter PID to kill
Done
(Optional)
Set to path environment so that you can access this file from anywhere.
Most probably you will know how to add an new path to env. But here's how if you don't
Step 1 of 4
Search ENV on start menu
Step 2 of 4
Select Environment Variables
Step 3 of 4
Select 'path' and click Edit button
Step 4 of 4
Click 'New' add the path where .bat file is stored. Since I saved it on '../Documents/bats' folder I am adding this path. Your path will depend on where you save this file.
Open CMD and test. Remember you filename will the word to run this file. Since I saved the .bat file as 'killport.bat' => 'killport' is the word to run it.
if do enjoy!
else share how you done it here
lsof -i :3000 | awk '/[1-9]/ {print $2}' | xargs kill -9
there is probably an easier way to do it