Kill process listening on a particular port

til command-line

Use the kill command in combination with the lsof(list of open files) command to kill process listening to a particular port. As described in a previous post, the lsof command helps us identify which process is listening to a particular port - Just pass the result of the lsof command to the kill command.

$ sudo kill -9 $(lsof -t -i:8080)

The below variation uses xargs to accomplish the same:

$ lsof -t -i:8080 | xargs kill -9

See Also