← Notes

TIL: Finding What Owns a Local Port

A quick macOS command for identifying the process that kept port 5173 busy after a development server stopped responding.

When a local server reports that port 5173 is already in use, ask the operating system which process is listening:

lsof -nP -iTCP:5173 -sTCP:LISTEN

-nP skips hostname and service-name lookups, so the output stays fast and shows the numeric port. The PID column identifies the process. I check the command name before stopping it rather than sending a signal to whatever number happens to appear.