See a List of All Open Ports using Mac Terminal


There are a few commands that you can make use of to list all the open ports using the Mac Terminal.


Example 1: Using the netstat command

    % netstat -an | grep LISTEN
    
    tcp6       0      0  *.50019                *.*                    LISTEN     
    tcp4       0      0  *.50019                *.*                    LISTEN     
    tcp6       0      0  ::1.42050              *.*                    LISTEN     
    tcp4       0      0  127.0.0.1.3306         *.*                    LISTEN     
    tcp4       0      0  127.0.0.1.33060        *.*                    LISTEN     
    tcp6       0      0  *.5000                 *.*                    LISTEN     
    tcp4       0      0  *.5000                 *.*                    LISTEN     
    tcp6       0      0  *.7000                 *.*                    LISTEN     
    tcp4       0      0  *.7000                 *.*                    LISTEN

    We have piped this command with grep to display only the ports that are open, which are displayed with the text LISTEN


Example 2: Using the lsof command

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap