How to Kill a port using bash terminal command?

If you have a service running on your system on a certain port and you want to kill it using bash you can make use of the kill command, the kill command can send a signal to a process to terminate it,


Say I have MySQL running on port 3306 or tomcat on 8080 and I want to kill it,

$ kill $(lsof -t -i:3306)
$ kill $(lsof -t -i:8080)

lsof: list open files

-t: to produce an output of lsof without headers with just the process identifier (PID)

Kill a Port
Kill a Port

Have Questions? Post them here!

Topics Coverage:

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram