Down Boy! (Kill processes by Port)

twitter logo github logo ・1 min read

Need to kill processes by port? Try this...

Cute dog


Save this bash script as downboy to your bin directory:

for PORT in $@
    PID=$(lsof -i :$PORT | awk 'FNR ==2 {print $2}')
    echo "kill -9 $PID"
    kill -9 $PID

Make downboy executable:

chmod +X ./downboy


Now you can easily close any number of processes by their port:

sudo downboy 80 8080 3000


twitter logo DISCUSS (2)
markdown guide

Will save a lot of ps -ef | grep on my machine - I needed this, thanks!


Back in the mists of time, I recall that either the IRIX or Solaris implementation of fuser had the ability to kill processes by port.

Classic DEV Post from Dec 21 '18

What is the hardest thing about learning to code?

Coding is hard. I struggled to learn for the first several years because I wasn't active within the dev community. What was the hardest thing you've experienced on your coding journey?

Alistair MacDonald profile image
I'm write web applications for education.