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!
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap