Coffee
← Blog Mac Productivity

Port 5000 in Use on Mac? It's AirPlay Receiver (Fix)

By FavTray ·

Written by the team behind FavTray, a Mac developer dashboard for the menu bar. We check every app we cover against its own site, docs or a hands-on test, and each post says which.

Short answer: On macOS Monterey and later, port 5000 is usually held by AirPlay Receiver, which shows up in lsof as ControlCenter. Turn it off in System Settings › General › AirDrop & Continuity (on Ventura to Sequoia: AirDrop & Handoff), or start your app on another port, for example flask run --port 5001. Don’t kill ControlCenter: macOS restarts it.

TL;DR

  • Confirm it (read-only): lsof -nP -iTCP:5000 -sTCP:LISTEN shows ControlCe.
  • Tahoe 26 and Golden Gate 27: System Settings › General › AirDrop & Continuity › AirPlay Receiver off.
  • Ventura, Sonoma, Sequoia: System Settings › General › AirDrop & Handoff › AirPlay Receiver off.
  • Keep AirPlay, move the app: flask run --port 5001, or -p 5001:5000 for a container.
  • Port 7000 too: same receiver, same fix.

Flask’s default port is 5000, so every Flask tutorial walks straight into this. Werkzeug, the server under flask run, even prints a hint when port 5000 is taken on a Mac: “On macOS, try searching for and disabling ‘AirPlay Receiver’ in System Settings.” Flask’s development server docs say the same.

What is using port 5000 on my Mac?

Monterey (macOS 12) made the Mac an AirPlay receiver, so you can stream from an iPhone or iPad to it. The receiver lives inside ControlCenter, the process that also draws Control Center in the menu bar, and it listens on two TCP ports:

That puts AirPlay on two ports plenty of dev tools use by default:

PortCommon dev tools that default to it
5000Flask, Docker’s registry image, ASP.NET Core’s Kestrel when no other URL is configured
7000Apache Cassandra’s internode port

Why did port 5000 stop working after a macOS update?

Before Monterey, a Mac could only send AirPlay, so nothing on the system listened on 5000 and Flask tutorials worked as written. Monterey added the receiver, and many developers discovered it was switched on only when a project that had run for years suddenly reported the port as busy. Security baselines such as the CIS macOS benchmark include a check to make sure AirPlay Receiver is disabled, which tells you it’s on unless someone turns it off.

So if your Flask app broke right after upgrading a Mac, or on a brand-new Mac, the update didn’t break your code. A new system service took the port.

How do I confirm it’s AirPlay and not my own app?

Run this read-only check:

# read-only
lsof -nP -iTCP:5000 -sTCP:LISTEN

AirPlay looks like this (lsof cuts command names to nine characters, hence ControlCe):

COMMAND     PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe   635 akash   11u  IPv4 0x4c2a9e1f0b7d33a1      0t0  TCP *:5000 (LISTEN)

If the COMMAND column says python or Python instead, it’s a Flask server you left running, not AirPlay. Jump to What if port 5000 is still busy?.

For a refresher on reading that output, see the lsof port mac cheat sheet.

How do I turn off AirPlay Receiver on a Mac?

Apple moved the switch twice. Find your macOS version under Apple menu › About This Mac, then use the matching path:

macOS versionWhere AirPlay Receiver lives
Golden Gate (27), Tahoe (26)System Settings › General › AirDrop & Continuity
Sequoia (15), Sonoma (14), Ventura (13)System Settings › General › AirDrop & Handoff
Monterey (12)System Preferences › Sharing

Steps for current versions, per Apple’s AirPlay to your Mac guide:

  1. Choose Apple menu › System Settings.

  2. Click General in the sidebar. You may need to scroll.

  3. Click AirDrop & Continuity (Ventura to Sequoia: AirDrop & Handoff).

  4. Turn off AirPlay Receiver.

  5. Check the port is free:

    # read-only: no output means nothing is listening on 5000
    lsof -nP -iTCP:5000 -sTCP:LISTEN

What you give up: you can’t AirPlay from your iPhone or iPad to this Mac until you switch it back on. Changing “Allow AirPlay for” isn’t enough: switch the receiver itself off. If your Mac is managed by your employer (MDM), the switch may be greyed out, so move your app instead.

Don’t kill ControlCenter. macOS relaunches it in moments and it grabs the port again, and in the meantime your menu bar’s Control Center is gone.

How do I move Flask (or anything else) off port 5000?

If you use AirPlay to your Mac, leave it on and give your app another port. 5001 and 8000 are popular choices; skip 7000, since AirPlay has that one too.

ToolHow to change the port
Flask CLIflask run --port 5001, or export FLASK_RUN_PORT=5001
Flask via python app.pyapp.run(port=5001)
Docker container that listens on 5000docker run -p 5001:5000 ... (host port first)
Docker Composeports: ["5001:5000"]
Docker registrydocker run -d -p 5001:5000 registry:2, then push to localhost:5001
ASP.NET Coredotnet run --urls http://localhost:5001
Node / Express reading PORTPORT=5001 npm start

The Flask row trips people up. flask run never calls app.run(), and python app.py never reads the flask CLI’s options, so changing one does nothing for the other. Use the line that matches how you start the app. FLASK_RUN_PORT in a .flaskenv file only loads when python-dotenv is installed (Flask CLI docs).

Why does Flask start fine but the browser shows 403 Forbidden?

This one is confusing because nothing errors. Flask binds 127.0.0.1:5000, AirPlay listens on every address on port 5000, and macOS lets both exist because one is more specific than the other. Depending on how your browser resolves localhost, the request can land on AirPlay instead of Flask, and AirPlay answers with an empty 403 Forbidden.

Check who actually answered (read-only):

curl -sI http://localhost:5000 | grep -i '^server'

Server: Werkzeug/... is your app. Server: AirTunes/... is AirPlay Receiver, as developers have reported (example write-up). The fix is the same: turn off the receiver or move Flask to another port.

How do I keep Flask off port 5000 for good?

Changing the port on the command line every time gets old. Make it part of the project instead:

  1. Install python-dotenv in the project’s virtual environment: pip install python-dotenv.

  2. Create a .flaskenv file next to your app:

    FLASK_APP=app.py
    FLASK_RUN_PORT=5001
  3. Commit .flaskenv so teammates on Macs get the same port. Keep secrets in .env, not here.

  4. Run flask run as usual. It now starts on 5001.

If you also use Docker Compose, keep the container’s internal port at 5000 and change only the host side ("5001:5000"), so nothing inside the image needs to change.

What if port 5000 is still busy with AirPlay off?

Then something else holds it, and lsof names it:

  1. An old Flask server. With the debug reloader on, Flask runs two Python processes, so lsof may list two PIDs. Stop it with Ctrl+C in its terminal, or kill PID if the terminal is gone.
  2. A container. com.docker.backend in the COMMAND column means a container publishes 5000. Find it with docker ps --filter publish=5000 and docker stop it.
  3. Another user’s process. If lsof prints nothing, try sudo lsof -nP -iTCP:5000 -sTCP:LISTEN.

The full walkthrough for stubborn ports, including orphaned servers and TIME_WAIT, is in address already in use on Mac. If you just want the command to free a port, the kill port mac guide has it.

Does port 7000 need the same fix?

Yes. The receiver listens on 5000 and 7000 together, and turning off AirPlay Receiver releases both. If you run Cassandra, or any service whose default is 7000, the same check applies:

# read-only
lsof -nP -iTCP:7000 -sTCP:LISTEN

Is there a quicker way to spot this next time?

We make FavTray, so weigh our take accordingly. FavTray’s Ports lists every listening TCP port in the menu bar and labels system processes such as ControlCenter, so you can tell at a glance whether 5000 belongs to AirPlay or to a forgotten Flask app. Kill asks for confirmation, and system ports can be hidden so you don’t stop them by accident.

Listing, search and filters are free with no limit; Free includes 10 kills a day, and Pro is $4.99 once for unlimited kills. For this particular port, though, the right fix is the System Settings switch above, and no app needs to be involved.

Try FavTray Free

One free Mac menu bar app: notch island, ports, keep-awake, clipboard, eye rest, and Claude and Codex limits.

Download Free

Frequently Asked Questions

Why is port 5000 already in use on my Mac?

Since macOS Monterey, a Mac can receive AirPlay from an iPhone or iPad, and the AirPlay Receiver listens on ports 5000 and 7000. In lsof it appears as ControlCenter (shortened to ControlCe). It's a macOS feature, not malware and not your app. Turn off AirPlay Receiver in System Settings, or run your server on a different port.

How do I turn off AirPlay Receiver on macOS Tahoe or Golden Gate?

Open System Settings, click General in the sidebar, then AirDrop & Continuity, and switch off AirPlay Receiver. On macOS Ventura, Sonoma and Sequoia the same switch is under General › AirDrop & Handoff. On Monterey it's a checkbox in System Preferences › Sharing. If your Mac is managed by an organisation, the setting may be locked.

Can I just kill ControlCenter to free port 5000?

Don't. ControlCenter also runs the menu bar's Control Center, and macOS relaunches it within moments, so it takes port 5000 straight back. Killing it gains you nothing. Turn off AirPlay Receiver in System Settings instead, or move your own app to a port such as 5001 or 8000.

How do I run Flask on a different port on Mac?

Use 'flask run --port 5001', or set FLASK_RUN_PORT=5001 in your shell or .flaskenv (which needs python-dotenv installed). If you start the app with 'python app.py', change app.run() to app.run(port=5001) instead, because 'flask run' ignores app.run() and 'python app.py' ignores the flask CLI options.

Is port 7000 also used by AirPlay on Mac?

Yes. Apple's own list of ports used by its software includes TCP 5000 and 7000 for AirPlay, and the AirPlay Receiver on a Mac listens on both. Anything that defaults to 7000, such as Apache Cassandra's internode port, will collide with it too. The same switch in System Settings frees both.