Stop the process occupying a port on Mac

Kill whatever is listening on a port (e.g. a stuck dev server).

macOSlsofProcessesDiagnosticsMedium risk
Run the command below, replacing 8080 with your port. Any process listening on it is terminated. Run the lookup command first if you are not sure what is using the port.

01Command

Command
$ lsof -ti :8080 | xargs kill

02What it does

lsof -ti :8080 prints just the PIDs of processes using port 8080, and xargs kill sends each a SIGTERM — the polite termination signal that lets the process clean up. Prefer identifying the process (see Related) before killing it blindly.

03Risk

RiskMedium risk
CompatibilitymacOS 10.11 El Capitan – 15 Sequoia
!Warning: This force-terminates processes without saving their state. Unsaved work in the target app is lost.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2025-11-16 · Category: Developer

06Related solutions