Developers
Port 5000 or 7000 is in use on a Mac: AirPlay Receiver
Apple lists TCP ports 5000 and 7000 for AirPlay. When AirPlay Receiver is on, a dev server cannot use these ports.
Symptoms
- A Flask or other dev server on port 5000 stops with “address already in use”.
lsofshowsControlCenteron port 5000 or 7000.curl localhost:5000returns a reply that is not from your app.
Likely causes
- AirPlay Receiver. AirPlay Receiver lets other Apple devices stream to the Mac. Apple lists ports 5000 and 7000 for AirPlay.
- Another server. If the process is not ControlCenter, another app uses the port. See Port already in use on a Mac.
How to check
Find the process on port 5000.
lsof -nP -iTCP:5000 -sTCP:LISTENOutput A line with
ControlCenterin the COMMAND column means AirPlay Receiver.Find the process on port 7000.
lsof -nP -iTCP:7000 -sTCP:LISTEN
How to fix it
The easiest fix is to use another port for your dev server, such as 5001 or 8000.
To free the ports, choose Apple menu > System Settings > General > AirDrop & Handoff. Newer versions call it AirDrop & Continuity.
Turn off AirPlay Receiver.
On macOS 12, the setting is in System Preferences > Sharing > AirPlay Receiver.
Run lsof again to make sure that the port is free.
lsof -nP -iTCP:5000 -sTCP:LISTEN
Questions
Can I keep AirPlay Receiver on?
Yes. Run your server on another port. You need to turn off AirPlay Receiver only if the app must use port 5000 or 7000.
Why does the server work on Linux on port 5000?
AirPlay Receiver is a macOS feature. Other systems do not use this port for it.
Sources
- Apple Support: TCP and UDP ports used by Apple software products
- Apple Support: Change AirDrop & Continuity settings on Mac
- lsof(8), man page installed with macOS 27.2
Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.