Port 5000 already in use on macOS? It's AirPlay Receiver
Short answerOn macOS 12 Monterey and later, the AirPlay Receiver feature listens on ports 5000 and 7000, so a server started on port 5000 fails with “address already in use”. Turn AirPlay Receiver off in System Settings, or run your server on a different port such as 5001.
What is happening
Flask's default port is 5000, and plenty of tutorials use 5000 or 7000. Since Monterey, a system process called ControlCe (Control Center) listens on both ports so your Mac can receive AirPlay streams. You can confirm it:
lsof -nP -iTCP:5000 -sTCP:LISTENThe COMMAND column shows ControlCe, not your app.
Fix 1: turn off AirPlay Receiver
- Open System Settings.
- Go to General, then AirDrop & Handoff.
- Switch AirPlay Receiver off.
On Monterey the same switch is in System Preferences under Sharing. The ports are released immediately.
Fix 2: use another port
If you want to keep AirPlay Receiver, move your server. For Flask that is flask run -p 5001. Do not kill Control Center: it is a system process and macOS will restart it.
Spotting it in Portmole
Portmole lists system processes under Apps and Other, so you can see at a glance that :5000 belongs to Control Center and not to one of your servers.
Frequently asked questions
What uses port 5000 on macOS?
AirPlay Receiver, run by Control Center, listens on ports 5000 and 7000 on macOS Monterey and later.
Can I kill the process on port 5000 on Mac?
You shouldn't. It is a system process and macOS restarts it. Turn off AirPlay Receiver in System Settings instead, or use a different port.
Does this affect port 7000 too?
Yes. AirPlay Receiver listens on both 5000 and 7000.
Skip the terminal
Portmole shows every port your Mac is listening on and closes any of them with one click. Free, signed and notarized, about 7 MB.
Download Portmole for Mac