MacOS How to see which process is listening on a port.

How to check ports in use Linux & MacOS

Sometimes, when trying to start server processes on your Mac or Linux server, you may get a message that the port is already in use.

So, how do you work out what is using the port, and how do you fix it?

To see which process is using the port use this command:

sudo lsof -nP -iTCP:5000 | grep LISTEN

In this case, we’re looking for what is using port 5000. If anything is using the port, you will see something like this:

Python  78500 bob    5u  IPv4 0xdd33030855f89bcb      0t0  TCP (LISTEN)

This is saying that Python is listening in port 5000 on a process with the id, 78500.

Once you have the process ID you can kill it using the command:

kill 78500

Mac check port usage from the command line:

The above instructions work from the command line, but you can also do this using the System Activity Monitor. Click on the Network tab and then click on the Ports column to sort by port. You can then scroll through to see which process uses a given TCPIP port number.

Using MacOS Activity Monitor to address "mac check port usage"

MacOs find process using port?

We show two methods above, one using the command line and the other using the MacOS GUI Activity Monitor.

The above information should have addressed the frequently asked questions, “Mac check port usage?” and “Macos check port in use?” but if you still have questions, please leave a comment below, and I will get back to you.

You May Also Like…

Find similar blogs in these categories: Apple MacOS / OSX | Linux
1 Comment
  1. chris

    activity monitor shows the number of used ports and not the ports that an app is listening on

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.