This content originally appeared on David Walsh Blog and was authored by David Walsh
Once a week I have to deal with a zombie process or try to start a process that’s already running on its designated port. In most cases I use macOS’s Activity Monitor to kill the process, which is time-consuming. What if we could just kill a process on a given port from command line? Well, we can!
To terminate a process on a given port, install kill-port
and starting nuking those zombies via:
# yarn global add kill-port # Kill processes on multiple ports kill-port 6060 8000
If you want to programmatically kill a port that you want to ensure your app will run on, you can do that as well:
const kill = require('kill-port') kill(6060, 'tcp') .then(console.log) .catch(console.log)
I look forward to incorporating this library into my Node.js sites so that I can clear the way for a given port and avoid zombie processes.
The post Terminate Process on a Port from Command Line appeared first on David Walsh Blog.
This content originally appeared on David Walsh Blog and was authored by David Walsh

David Walsh | Sciencx (2021-10-10T17:42:32+00:00) Terminate Process on a Port from Command Line. Retrieved from https://www.scien.cx/2021/10/10/terminate-process-on-a-port-from-command-line/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.