Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm on an OS X mountain lion laptop and have a couple of Vagrant boxes on it. I'm trying to figure out which process is listening on port 8080. My variations produce like a hundred lines but none with specific port number. I'm assuming something like

nestat -XXX | grep 8080


share|improve this question

migrated from serverfault.com Aug 3 '13 at 2:00

This question came from our site for system and network administrators.

Is this in a home setting or professional environment? –  Lucas Kauffman Aug 3 '13 at 1:53
well, recreating an server enviro locally. if you want to move to different site, that's fine. Different versions of netstat support different arguments. –  timpone Aug 3 '13 at 1:57
Okay then sir, everything seems in order here, please carry on and have a nice day. –  Lucas Kauffman Aug 3 '13 at 1:59

5 Answers 5

up vote 18 down vote accepted

Unfortunately on OSX you're stuck with the BSD netstat which will not show you the process ID that is attached to a given port. What you have to do instead is use lsof. The syntax you'll need to use is:

lsof -i :8080

This will print out gobs of information, most of which you don't care about, but the fields are well labeled. For example, check out this example output.

lsof -i :53237
GoogleTal 927 guest   29u  IPv4 0x2c3f7f95244855c3      0t0  TCP localhost:53237 (LISTEN)

This tells me that port 53237 is in use by process ID 927. When reading the COMMAND field keep in mind that this output is truncated, in reality the full name of the binary is GoogleTalkPlugin.

share|improve this answer
thx, this gets me a lot closer, it's going to a fairly generic VBoxHeadl - is there any way to see which VirtualBox instance (have two right now) or am I asking way too much (propably the latter). thx –  timpone Aug 3 '13 at 2:07
@timpone: I don't know enough about VirtualBox to help you down that path. You can check the process command line to see if it's listed there, or use lsof -p PID and browse the list of open files until you find it. –  Scott Pack Aug 3 '13 at 2:14
cool, thx for help –  timpone Aug 3 '13 at 2:17

From man netstat

-p, --program Show the PID and name of the program to which each socket belongs.

I usually just do this: netstat -antup | grep 8080

share|improve this answer
hmm... this sounds like what I'd like but this is giving me different options on OS X for -p -p protocol Show statistics about protocol, which is either a well-known name –  timpone Aug 3 '13 at 1:58
@timpone: The -p to display the PID is a GNU netstat command whereas OSX uses BSD netstat. –  Scott Pack Aug 3 '13 at 2:10

This is what I like to use when looking for a listening port's PID. For Linux use: netstat -tunlp

  • n network
  • l listening ports
  • p process
  • t tcp
  • u udp

Additional information can be found in the man pages.

share|improve this answer

To find out specific port use below netstat command

  netstat -an | grep ':8080'
share|improve this answer

The below command shows the connection:

netstat -antop | grep :8080

For viewing the complete flow in realtime you could use watch:

watch -d -t -n 1 'lsof -n -i :8080'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.