DEV Community

Cover image for How to Kill a Process Running on a Port

How to Kill a Process Running on a Port

Johnny Simpson on September 18, 2022

It is common in Node.js and other languages to run a script on a certain port. Since ports can come in and out of use, it's also common to get the ...
Collapse
 
m1randasandro profile image
Sandro Miranda

neat. that happens more often than we'd wanted to.
btw, i usually do sudo kill -9 $(sudo lsof -t -i:3000) to get the job done real quick.

Collapse
 
smpnjn profile image
Johnny Simpson

Nice, that's a pretty simple way of doing it

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Sounds a bit pointless, given how linux already has the right tools for the job 🤔

Collapse
 
smpnjn profile image
Johnny Simpson

yeah I don't think you need a separate package for it either really. I guess it's just a wrapper for the basic linux commands.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

It's a lot of code for what could essentially be a one-liner though 😐

Collapse
 
Sloan, the sloth mascot
Comment deleted
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Unless many of your servers are running windows, it doesn't just sound pointless, but actually is.

Collapse
 
decker67 profile image
decker

Good tip.

Collapse
 
hilleer profile image
Daniel Hillmann

Nice. I wrote a small CLI tool to help you also do this. Cross platform ofc.

npmjs.com/package/kill-port-process

Collapse
 
jashandeep31 profile image
Jashandeep Singh

Thanks