Need to kill processes by port? Try this...
Setup
Save this bash script as downboy to your bin directory:
#!/bin/bash
for PORT in $@
do
    PID=$(lsof -i :$PORT | awk 'FNR ==2 {print $2}')
    echo "kill -9 $PID"
    kill -9 $PID
done
Make downboy executable:
chmod +X ./downboy
Usage
Now you can easily close any number of processes by their port:
sudo downboy 80 8080 3000
Bye-bye.
 


 
    
Top comments (2)
Back in the mists of time, I recall that either the IRIX or Solaris implementation of
fuserhad the ability to kill processes by port.Will save a lot of
ps -ef | grepon my machine - I needed this, thanks!