mac close open port code example Example 1: kill port mac terminal sudo lsof -i <Port> sudo kill -9 <PID> Example 2: release a port in mac sudo lsof -i :<port>