The Frustrating Port ConflictI was ready to test a new Flask API last week, but macOS had other plans. Instead of the usual 'Running on http://127.0.0.1:5000', my terminal spit back a familiar, yet annoying roadblock:
Error: listen EADDRINUSE: address already in use :::5000
If you build tools with Node.js, Python, or Ruby, you know the drill. Usually, this means a zombie process is still clinging to your port. But on modern macOS versions, the culprit isn't a forgotten terminal tab—it's the operating system itself squatting on your workspace.
The Culprit: AirPlay ReceiverStarting with macOS Monterey (version 12.0), Apple enabled 'AirPlay Receiver' by default. This service listens on ports 5000 and 7000 to catch incoming streams from your iPhone or iPad. Since Flask defaults to 5000 and many Docker-based microservices rely on 7000, this 'feature' creates an instant headache for developers who haven't touched their AirPlay settings.
Step 1: Confirm the ProcessDon't take my word for it—check the receipts first. Fire up your terminal and run the lsof command to see exactly who is camping on your port:
sudo lsof -i :5000
If AirPlay is the one causing the stir, your output will look like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ControlCe 482 user 18u IPv4 0x7b... 0t0 TCP *:commplex-main (LISTEN)
ControlCe 482 user 19u IPv6 0x7b... 0t0 TCP *:commplex-main (LISTEN)
Look at the COMMAND column. If it says ControlCenter, you've found the source. On macOS, the Control Center handles the AirPlay backend, and it won't let go of that port voluntarily.
Step 2: The Permanent FixKilling the process is a temporary band-aid. macOS is designed to be resilient; it will simply respawn the service like a persistent NPC. To reclaim your port for good, you need to toggle the feature off in your system settings.
- Open System Settings (or System Preferences).- Navigate to General in the sidebar.- Click on AirPlay & Handoff.- Locate the AirPlay Receiver toggle.- Turn it off.If you actually use AirPlay to mirror your phone to your Mac, you can try changing 'Allow AirPlay for' to 'Current User.' However, in my testing, the service often continues to bind to port 5000 anyway. Disabling it entirely is the only 100% reliable way to get your development environment back to normal.
Step 3: VerificationAfter toggling that switch, head back to your terminal. Run the check again:
lsof -i :5000
Silence is golden here. If the command returns nothing, your port is free. You can now start your dev server without that EADDRINUSE error crashing the party.
Alternative: Change Your Application PortIf you can't live without AirPlay Receiver, your only other option is to move your app to a different neighborhood, like port 5001 or 8080. For a Flask app, you'd adjust your startup command like this:
flask run --port 5001
In a Node/Express environment, you would update your entry point:
const PORT = process.env.PORT || 5001;
app.listen(PORT, () => console.log(`Server running on ${PORT}`));
Networking Tips for the RoadPort collisions are an occupational hazard. When I'm juggling multiple Docker containers or complex local routing, I use this IP Subnet Calculator to keep my networking logic straight. It is a quick way to double-check CIDR blocks and ensure local service addresses aren't overlapping in ways that cause weird routing loops. It runs entirely in your browser, which keeps your internal network configurations private.
By clearing out the AirPlay conflict now, you save yourself the recurring frustration of hunting down ghost processes every time you reboot your Mac.

