Finding the process ID of a process running on a specific port

Im in the process of redeveloping an existing site. Its a small site that whilst i develop i am running on rails built in server using port 3003. This means i can work on it on the server its destined to be applied without affecting the original site, (This will make it a breeze to switch from the current site to the new site). The problem is i keep starting the server, but forgetting to shut it down properly so when i goto start the server, the server is not running properly but the port is still being used.

To find the process ID of a process running on a particular port you can use:

/usr/sbin/lsof -i tcp:3003 -Fp|tr -d p

This will give you the process ID which you can then pass to kill to stop it completely.



Thursday, August 12th, 2010
Graham
Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>