Tuesday, January 11, 2022

How to kill a process running on particular port in Linux?


Linux/Ubuntu Commands To Kill Background Running Application Port

In spring boot application sometimes we try to stop application using Ctrl+c but background process will not stopped in that particular port so we need to kill exact port using following steps manually
 
1) List all 
 sudo lsof -t -i 
 
2)Search port which is used in application 
sudo netsat -lpn |grep :9500 

 3)Search id with exact port 
 sudo lsof -t -i:9500 

 4)List of id will be displayed to kill use below command
 kill 6230
 
 To List and kill all java 

Use the command

 sudo netstat -plten |grep java

used grep java as tomcat uses java as their processes.

It will show the list of processes with port number and process id

tcp6       0      0 :::8080                 :::*                    LISTEN      
1000       30070621    16085/java

the number before /java is a process id. Now use kill command to kill the process

kill -9 16085

-9 implies the process will be killed forcefully.

No comments:

Post a Comment