How to Kill a Process on a Port on Mac (localhost:3000, 5432, 8080)
The Silo Team · 5 min read · Updated September 27, 2026
The Problem: Something Is Already on That Port
You run npm run dev and get:
Error: listen EADDRINUSE: address already in use :::3000
This happens when a previous dev server didn't exit cleanly. The process is still running, holding the socket open.
The Basic Fix: lsof + kill
# Find what's on port 3000
lsof -i :3000
# Kill it (replace PID with the number from lsof output)
kill -9 PID
This works, but it has a critical flaw: it kills just that process. If your dev server is zsh → npm run dev → next-server, killing only next-server leaves the parent npm process running. It may respawn the server or remain as a zombie consuming memory.
The Correct Fix: Process Group Termination
# Get the PID of the port listener
PID=$(lsof -ti :3000)
# Get the PGID (process group ID)
PGID=$(ps -o pgid= -p $PID | tr -d ' ')
# Kill the entire process group gracefully
kill -TERM -$PGID
# If still alive after 3 seconds:
sleep 3 && kill -KILL -$PGID 2>/dev/null
This terminates the entire parent → child process hierarchy, ensuring no zombie workers remain.
Common Dev Port Reference
| Port | Common Service |
|---|---|
| 3000 | Next.js, React dev server, Rails |
| 4000 | Gatsby, Nuxt.js |
| 5432 | PostgreSQL |
| 6379 | Redis |
| 8080 | Java apps, various APIs |
| 8888 | Jupyter Notebook |
| 9000 | PHP-FPM, SonarQube |
| 27017 | MongoDB |
Using MacPilot's Port Manager
MacPilot's Port & Socket Manager shows you every listening socket alongside its full process ancestry tree (zsh → npm → next-server) and working directory. One click sends a graceful SIGTERM to the entire process group. If the process is stubborn, escalate to SIGKILL with a second click.
It also flags sockets bound to 0.0.0.0 (publicly exposed) vs 127.0.0.1 (localhost-only) — a quick security audit with no extra tools.
Keep reading
How to Free Up Disk Space on Mac: The Developer's Complete Guide
From APFS clone-aware deduplication to DerivedData nukes and Docker.raw shrinking — the most complete storage reclaim guide for macOS engineers.
node_modules Taking Up Space on Mac: Find and Delete Them All
How to find every node_modules directory across your Mac, identify safe candidates for deletion, and clear npm/yarn/pnpm caches too.