The previous answers didn't work on Snow Leopard, but I was trying to use 'netstat -nlp' until I saw the use of 'lsof' in the answer by pts.
I am a Linux guy. In Linux it is extremely easy with netstat -ltpn or any combination of those letters. Others are very ugly and very difficult to remember when troubleshooting. I made a small script to see not only who is listening where but also to display established connections and to which countries. Works on OSX Siera.
Mac OS X – List Open Ports
For macOS I use two commands together to show information about the processes listening on the machine and process connecting to remote servers. In other words, to check the listening ports and the current TCP connections on a host you could use the two following commands together. Listen now. Learn more. Ask Question. Asked 8 years, 10 months ago. Active 8 months ago.
Membership
Viewed k times. Prepend sudo followed by a space if you need information on ports below See the comments for more options. Per Lundberg 2, 1 1 gold badge 25 25 silver badges 33 33 bronze badges. Prefix this with sudo to see processes you don't own. On my OSX Might give that a try, as it enables you to run it without entering a password. It works on at least as old as Snow Leopard.
This is going in my dotfiles.
Spotlight on Network Utility to List Ports
I search every few months and always come upon this answer. Rog Rog 4, 1 1 gold badge 10 10 silver badges 4 4 bronze badges. This did the job for me, cheers OS X Also works on Mountain Lion Also works on Yosemite The -i option makes it significantly faster. In my application this made quite the difference. Works with El Capitan Immigration Lawyers in Canterbury 24 Oct Reply.
Good post. I am going through many of these issues as well..
Dave 24 Sep Reply. Johan Haleby 24 Sep Reply. Thanks for the tip! Amir 19 Dec Reply. Ben 18 Feb Reply. I think lsof gives you much more information than you can get with the current Mac OS X version of the netstat command. For instance, here's the output from a netstat command where I try to look at TCP information:.
terminal - How can I list my open network ports with netstat? - Ask Different
Personally I think this netstat output isn't very useful, and I much prefer the lsof command information that gives you the name of the process, the PID, PPID, and much more. Before going, although the following lsof commands aren't directly related to Mac OS X networks, ports, sockets, or the internet, they are very useful whenever you need to know what files are in use by a particular user or application process.
To see the files opened by a particular process such as the "firefox" process shown above , give the lsof command the PID process ID , like this:. I promise, you'll be amazed at the files an application like Firefox keeps open at any one time.
- mac limited edition collections 2012.
- Your Answer;
- What is Listening Port;
- root user on mac os x.
- Conclusion;
It currently has a reference to every image file on my Mac Desktop, which strikes me as pretty crazy. As a final note, when debugging OS X network ports, internet connections, etc.