Killing a process that listening on a port

Sometimes you may want to stop a server application that is running on a pre-defined port number.

lets give an example; if you have a tomcat server running on port 8080, you don’t have the process number to execute the kill command, and you don’t want to go through the ps hell.

here’s what you should do to stop (kill) the tomcat process:

first, make sure that the server is running on that port :
netstat -nap | grep 8080

then, kill the process that is running on that port using this command:
fuser -k 8080/tcp

this will kills the process that listens on port 8080

note: the fuser binary resides in different places based on your linux distribution. So, to find its exact binary location, uses this command:
whereis fuser

Advertisements

About SoCRaT

Software Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s