How to Find Who/What is Listening on TCP Ports on Mac.
Occasionally it’s possible you’ll end up in a scenario the place you’re looking for to search out what open TCP connections are in a listening state on a Mac. This will be helpful whether or not you’re troubleshooting explicit network points, or just trying to determine which processes are listening on particular ports on a Mac.
We’ll be using the command line lsof device to search out out what/who’s listening on open TCP connections on a Mac, making this most acceptable for superior Mac customers who’re snug with the Terminal and sudo.
How to Find What Listens on TCP Ports on MacOS
The command we’ll use right here is aimed toward MacOS Ventura and MacOS Monterey, however ought to work on older MacOS variations as properly:
- Open the “Terminal” software from /Applications/Utilities/ or by means of Spotlight with Command+Spacebar
- Type the next command:
- Hit enter and use the admin password when requested to execute the command and see an inventory of what’s actively listening on which TCP ports on the Mac
sudo lsof -iTCP -sTCP:LISTEN -P -n
You will see an inventory of instructions / processes, the method ID (PID), sort (IPv6 vs IPv4), device, node (TCP on this case), and the port.
With this data you may decide your next steps, relying on what your targets are.
For these curious, let’s breakdown the command and the varied flags used right here used right here:
- sudo: Runs the command with superuser privileges, permitting it to show network connections opened by all customers, together with root.
- lsof: Lists all open recordsdata on the system, together with open network connections.
- -iTCP: Filters the outcomes to indicate solely TCP connections.
- -sTCP:LISTEN: Filters the outcomes to indicate solely listening TCP connections.
- -P: Disables port title decision, displaying solely port numbers.
- -n: Disables hostname decision, displaying solely IP addresses.
The lsof command is sort of highly effective, and we’ve coated it’s utilization earlier than with figuring out what apps or processes are interacting with a specific file, discovering what processes are using web connectivity, displaying open network connections, listening all open web connections, and more.
BTW when you favor the GUI, you may check out the Sloth app, which is principally a GUI front-end to lsof, and accessible as a free obtain, and Activity Monitor has restricted help for related options as properly.
Do you might have any related tips, instructions, or instruments you employ to search out what or who’s listening to any given TCP port on a Mac? Let us know within the feedback beneath.
Check out more article on – How-To tutorial and latest highlights on – Technical News, Apple Products