Port 5000 in Use on macOS (AirPlay Receiver)

Since macOS Monterey, Apple's AirPlay Receiver occupies port 5000. Here is how to free it for Flask, Django, or any other app.

Updated April 20264 min read

The problem

You try to start a Flask app, Django, or any server on port 5000 and get an error:

OSError: [Errno 48] Address already in use

Or in Node.js:

Error: listen EADDRINUSE: address already in use :::5000

What is using port 5000? Apple's AirPlay Receiver.

Confirm the cause

$ ptrm 5000
  Port 5000
  PID    610
  Name   ControlCenter
  Cmd    /System/Library/CoreServices/ControlCenter.app

# Or with lsof:
$ lsof -i :5000
COMMAND        PID USER   FD   TYPE DEVICE NODE NAME
ControlCenter  610 dev    28u  IPv4 0x...  TCP  *:commplex-main (LISTEN)
ControlCenter  610 dev    29u  IPv6 0x...  TCP  *:commplex-main (LISTEN)

If you see ControlCenter, it is AirPlay Receiver. This is a macOS system process -- you cannot simply kill -9 it (it will restart immediately).

Fix 1: Disable AirPlay Receiver (recommended)

macOS Ventura, Sonoma, Sequoia (13+)

  1. Open System Settings
  2. Go to GeneralAirDrop & Handoff
  3. Turn off AirPlay Receiver

macOS Monterey (12)

  1. Open System Preferences
  2. Go to Sharing
  3. Uncheck AirPlay Receiver

Port 5000 (and 7000) will be freed immediately. No restart required.

Fix 2: Use a different port

If you want to keep AirPlay Receiver enabled, change your app's port:

# Flask
$ flask run --port 5001

# Django
$ python manage.py runserver 5001

# Node.js / Express
$ PORT=5001 node server.js

# Docker
$ docker run -p 5001:5000 my-flask-app

Fix 3: Command line (temporary)

You can kill ControlCenter, but it will restart within seconds:

$ kill $(lsof -ti :5000)
# Port 5000 is free... for about 3 seconds

This is not a permanent fix. Use Fix 1 or Fix 2 instead.

Which ports does AirPlay use?

PortProtocolService
5000TCPAirPlay Receiver (HTTP)
7000TCPAirPlay Receiver (RTSP)
49152+UDPAirPlay audio/video streams

Affected frameworks

Port 5000 is the default for many popular frameworks. Since macOS Monterey, all of these need a port change or AirPlay disabled:

FrameworkDefault PortChange to
Flask5000flask run -p 5001
Django (runserver)8000 (safe)No change needed
ASP.NET Core5000--urls http://localhost:5001
Phoenix (Elixir)4000 (safe)No change needed
Streamlit8501 (safe)No change needed
Tip: Flask 2.3+ changed its default port to 5001 on macOS specifically because of this issue. If you upgrade Flask, you may not need to change anything.

portrm detects system services

portrm tells you what is on any port, including system services like AirPlay Receiver. No more guessing.