The Linux operating system considers everything as a file. So first of all, use lsof (list of open files) Linux command to identify the process id (PID) of the running process on any port. Once you get the process id, you can use the kill command to kill that process using the PID.
Kill a Process Running on Port
First of all, find out the PID (process id) of the running process on a specific port. For example, a process is running on port 3000. To find its process id, execute:
lsof -t -i:3006279
Now you have the PID of the process running on a port. Use the kill command to terminate that process by its PID.
sudo kill -9 6279
You will notice that the process running on the specific port is terminated.
Short Version of Command
You can also combine both of the above commands and run it as follows:
sudo kill -9 $(sudo lsof -t -i:3000)
In this faq, you have learned to terminate a process running on a specific port.