How to determine what process is listening to a port under OS X
Many times, people are confused when they try to run a program, and it tells them that it can’t bind to a port because the port is already in use. How can you figure this out? First, like most good things, you have to open up Terminal.app.
Once there, you need to use sudo, or get root through su.
The quickest way to see if a port is in use is to use netstat and grep. Let’s say were looking for port 80:
$ netstat -an | grep 80
tcp4 0 0 *.80 *.* LISTEN
2a0c880 stream 0 0 2c02f78 0 0 0 /private/var/run/cupsd