Stop the process occupying a port on Mac
Kill whatever is listening on a port (e.g. a stuck dev server).
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 kill02What 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
!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
- lsof — list open filesEvidence: lsof -t prints PIDs only, suitable for piping to kill.
Last verified: 2025-11-16 · Category: Developer