34

How do I see which processes have open TCP/IP ports in Mac OS X?

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
yazz.com
  • 3,311
  • 6
  • 32
  • 48

5 Answers5

35

One alternative is the use of the lsof utility; specifically, lsof -i 4tcp will list all processes with some sort of TCP IPv4 network sockets open. The manpage of lsof will provide you with detailed information on how to use the utility and how to interpret the output.

ayaz
  • 11,068
  • 1
  • 21
  • 26
16

If you are interested in a specific port, you can use this example:

lsof -i 4tcp:8080 -sTCP:LISTEN

If you would only like to get the process id, you can run this:

lsof -i 4tcp:8080 -sTCP:LISTEN -Fp
Zsolt Balogh
  • 161
  • 1
  • 2
4

I use the command below when I want to see everything that's on a specific port for either TCP or UDP. The -n option disables attempting to resolve the IP addresses into domain names, and the -P disables attempting to figure out the name of a particular port. Also, running as root will show you more processes than running as a normal user.

sudo lsof -iTCP:53 -iUDP:53 -n -P

1

use this: netstat -p tcp -p udp

together with this: lsof -n -i4TCP -i4UDP

ShifraSec
  • 21
  • 4
  • Welcome back to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on [answer]. There is also [tour] for the site tour, and [help] for the help center. – help-info.de Jul 01 '21 at 08:20
-1

This should be possible in a terminal window using the Netstat command.

And if you like the GUI way more:

With Mac OS X 10.5, the /Applications/Utilities folder contains a network utility called: Network Utility, see tab Netstat for these stats presented in a gui application, along with Ping, Lookup, Traceroute, Whois, Finger and Port Scan.

fretje
  • 10,692
  • 5
  • 40
  • 63