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

How to check ports in use Linux & MacOS

Sometime when trying to start server processes you may get a message to say 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. Simply 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 is using a given TCPIP port number.

MacOs find process using port?

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


Recent Posts

Popular Posts

You May Also Like…

Find similar blogs in these categories: Apple MacOS / OSX | Linux
Submit a Comment

Your email address will not be published.

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