Samuele Palazzi

"The more i see, the less i know"

Samuele Palazzi

"The more i see, the less i know"

How to kill process on a port

This method works always!

Most always we get involved in things that doesn’t stop or freeze without possibility to catch the error and we can easily adopt the command:

#with superuser privileges if we toggle for every user or without them if just for us
killall process_s_name
#or
kill -9 process_s_id

But sometimes process that freeze had just generated hundreds of other process that do not allow us to refresh the application and we can’t (in most cases) know everyone of them.

The only thing we know is that all of that processes works through a “port” so we can tell system to kill every process in there and getting things done

This is a real effective solution for GNU/linux and in general in Unix-like systems(yes! it works on MAC OS too).

i.e. if we would like to kill JEKYLL local server(port 4000) on us that always generates itself many other processes we can easily do like this:

#with superuser privileges
kill `sudo lsof -t -i:4000`