To find out which port numbers are being used on your Mac, you can use the lsof
(List Open Files) and netstat
commands in the terminal. Here are two methods:
Using lsof to Find Open Ports
You can use the lsof
command to list all the open files and find which ports are being used.
Open the Terminal and type the following command:
sudo lsof -i -P -n
Explanation:
-i
lists all network files.-P
shows port numbers instead of service names.-n
avoids resolving hostnames.sudo
is required to show all the information, including ports in use by system processes.
sudo lsof -i :<port_number>