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.

Applies to: macOS 12 Monterey and later. The setting is in General > AirDrop & Handoff, or AirDrop & Continuity in newer versions.Checked: 29 October 2026

Symptoms

  • A Flask or other dev server on port 5000 stops with “address already in use”.
  • lsof shows ControlCenter on port 5000 or 7000.
  • curl localhost:5000 returns 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

  1. Find the process on port 5000.

    lsof -nP -iTCP:5000 -sTCP:LISTEN

    Output A line with ControlCenter in the COMMAND column means AirPlay Receiver.

  2. Find the process on port 7000.

    lsof -nP -iTCP:7000 -sTCP:LISTEN

How to fix it

  1. The easiest fix is to use another port for your dev server, such as 5001 or 8000.

  2. To free the ports, choose Apple menu > System Settings > General > AirDrop & Handoff. Newer versions call it AirDrop & Continuity.

  3. Turn off AirPlay Receiver.

  4. On macOS 12, the setting is in System Preferences > Sharing > AirPlay Receiver.

  5. 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

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.