Kill a process by port

· 1 min read

How to kill a process with a given port:

On linux:

function killPort {
  kill -9 $(lsof -t -i:$1)

On mac:

function killPort {
  kill -9 `netstat -vanp tcp | grep $1 | head -n 1 | awk '{ print $9 }'`

And for all plateforms, with Node (and npx) installed:

npx fkill-cli :3001

with a cli tool called fkill, that can kill anything by all the ways you want:

You can find this page with theses search keywords:

/ node / fkill / cli /
Thanks for reading!
I'm Mathieu TUDISCO, a lead developer at Linkvalue .
You can find me anywhere with @mathieutu.
As a start you can follow me on Twitter or want to find out more about me or the blog.