Find which process is utilizing a port and kill it

Step 1. Use the list open files command to find the process using port 5434, for example.

sudo lsof -i tcp:5434

E.g. output:

COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 55746 work   18u  IPv4 0x97cf67a7c0ce1ffb      0t0  TCP *:sgi-arrayd (LISTEN)
com.docke 55746 work   19u  IPv6 0x97cf67a7dd4c56d3      0t0  TCP localhost:sgi-arrayd (LISTEN)

Step 2. Kill the process by PID:

sudo kill -12 55746

Done!

Leave a Reply

Your email address will not be published. Required fields are marked *

*