How to find the process that is running on a given port in OSX

I want to run a web application on my local OSX Lion machine. When I go to http://localhost:8080 there is already a process running so I get the following message:

Status Code: 404

Exception: Request URL / not found.<br><br>
Stacktrace:

Generated by Winstone Servlet Engine v0.9.10 at Wed Nov 30 13:01:15 CET 2011

How can I find the process that runs on this port under OSX. I found several entries that do the same on Linux but they do not seem to work in OSX.

Thanks a lot.


Update 1: I running the command lsof -i -P | grep 8080 results in the following output

WebProces 174 petersmith   20u  IPv6 0xffffff80147e6cc0      0t0  TCP localhost:50059->localhost:8080 (ESTABLISHED)

But this does not tell me which process is responsible for creating the html output that I get in my browser, when accessing the URL

Update 2: I should mention that I want to install Jenkins CI on my machine and there is already an installation present which seems to have a problem on my machine.


In a very general way:

sudo lsof -i -P

… will list you all processes running on certain ports. See this answer for more details.


In your special case, Jenkins is already running. This Stack Overflow question has more information: Can not run Jenkins on Mac. The solution seems to be:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

… which is also related to the similar Stack Overflow question: How to stop Jenkins installed on Mac Snow Leopard?