Tuesday, January 22, 2013

How to get process id by port number at mac OSX

When some application listening on some port it could be problem to find out which application it is. On mac OSX is problem to get process id by port number because following command doesn't work:
netstat -p
Mac OSX 10.8 and earlier doesn't support switch '-p' in netstat command. However there is simple workaround. There is command 'lsof' which list open files and their process ids. You can list processes which are listening like this:
lsof -i | grep LISTEN
It's useful to see port number instead of service name running on such port. It's better to see :8080 instead of 'http-alt'. It could be done like this:
lsof -i -P | grep LISTEN

No comments:

Post a Comment