How to Find the Process ID by Port on macOS
1 min readMay 11, 2017
If it ever occurs to you that a process wouldn’t start under a desired port, it is possible to check which process is currently occupying that port.
In order to do a grep search, type the following command in your terminal and replace 8080
with the port you are investigating:
$ lsof -n -i :8080 | grep LISTEN
You will get a list of processes that are listening to port 8080
(in this case, it is process ID 19477
). If no process is listening on that port, you won’t get any result.
nginx 19477 matthagemann 6u IPv4 0xe9b6ad5cd425f509 0t0 TCP *:http-alt (LISTEN)
To kill process ID 19477, use $ kill 19477
.