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!
Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -