Dhiru · dev watch
What's running on port 5000 on Mac, and how to stop it
Usually: Flask's dev server uses 5000. On macOS Monterey and later, the AirPlay Receiver (ControlCenter) also listens on 5000.
See what's on port 5000
Open Terminal and run:
lsof -nP -iTCP:5000 -sTCP:LISTEN
The first column is the app, the second its PID (process ID).
Stop it
kill <PID>
If it's still listed a few seconds later, use kill -9 <PID>. Or stop whatever is on 5000 in one go:
kill $(lsof -t -iTCP:5000 -sTCP:LISTEN)
If lsof shows ControlCenter, it's AirPlay: turn off System Settings → General → AirDrop & Handoff → AirPlay Receiver, or run your app on another port.
Other ports: 3000, 3001, 3306, 4000, 4200, 4321, 5173, 5432, 5555, 6006, 6379, 7000, 8000, 8080, 8081, 8787, 8888, 9000, 9229, 27017. All at once: see everything that's listening.