OSX show used ports or listening applications with their PID

On OSX you can display applications listening on a given port using the lsof the commands described below will show listening applications as well as the PID for each application

lsof -nP -i4TCP | grep LISTEN

lsof -nP -i4TCP:[PORT] | grep LISTEN

Where [PORT] is the given port you want to check for


lsof -nP -i4TCP:80 | grep LISTEN

Your output should look something similar to this :


idea      28856 ufasoli   15u  IPv4 0xdc1e11a68e7f918b      0t0  TCP 127.0.0.1:17434 (LISTEN)
idea      28856 ufasoli   52u  IPv4 0xdc1e11a690bab54b      0t0  TCP 127.0.0.1:6942 (LISTEN)
idea      28856 ufasoli  748u  IPv4 0xdc1e11a690b9dccb      0t0  TCP 127.0.0.1:63344 (LISTEN)
idea      28856 ufasoli 1076u  IPv4 0xdc1e11a68e7fa54b      0t0  TCP 127.0.0.1:54243 (LISTEN)
idea      28856 ufasoli 1082u  IPv4 0xdc1e11a67124254b      0t0  TCP 127.0.0.1:54266 (LISTEN)
rapportd  28871 ufasoli    5u  IPv4 0xdc1e11a665f15b6b      0t0  TCP *:51387 (LISTEN)
node      33709 ufasoli   28u  IPv4 0xdc1e11a66304354b      0t0  TCP 127.0.0.1:4200 (LISTEN)
java      34245 ufasoli  168u  IPv6 0xdc1e11a66dd5f11b      0t0  TCP *:52439 (LISTEN)
java      34245 ufasoli  182u  IPv6 0xdc1e11a6803af4db      0t0  TCP *:33389 (LISTEN)
java      34245 ufasoli  183u  IPv6 0xdc1e11a6803afafb      0t0  TCP *:8080 (LISTEN)

OSX show used ports or listening applications with their PID

On OSX you can display applications listening on a given port using the lsof the commands described below will show listening application...