How to kill a process by lsof port
Introduction
From this tutorial you would learn how to kill a process by lsof port info.
Environments
- Linux/Mac OS
The Process
First we start a process that listening to a port:
we found that the server port is 4000 Next we stop the process by run this command:
We found that the process is killed successfully.
Summary
The key command is kill -9 $(lsof -ti tcp:the_port)
You can find detail documents about the linux and lsof here: