Friday, November 18, 2016

How to kill a process on a port on ubuntu

Sometimes, when we strying to up an service and get message like: the port *** is used by another service. And we are notable to start our app to use that port. In that case, we are in need to free the port by stopping the running process. For this purpose a first we need to find out the process which is using that port.

By using the below query we can get the process id using this port:

sudo lsof -t -i:8080 [For this case 8080 is our reference port number]

to get the process in details, we can use:
ps -ef | grep


And then we can kill the process by :
kill -9

We can use the below command at once to kill the process:
sudo kill $(sudo lsof -t -i:8080)

No comments: