how to free ports on mac command line code example Example 1: running ports in mac sudo lsof -PiTCP -sTCP:LISTEN Example 2: kill port mac kill -9 <PID>