Mac OS | Find and Stop a Port in Use
How to find the process using a port on macOS with lsof and terminate it by PID
Search for a Port
Enter the port number as shown below and search for the process.
lsof -i :{port number}
When you actually search, the output appears as follows.
% lsof -i :8090
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 62421 kimkc 409u IPv6 0x891847b9306c0d75 0t0 TCP *:8090 (LISTEN)
Stop the Process Using the Port
Then enter the process ID (PID) and terminate the process.
kill -9 {PID}
The process ID (PID) found above is 62421. Run the command as follows to stop the process.
% kill -9 62421