A Quick Tutorial On macOS Monterey
Are you unable to start a service on your Mac because port 5000 is already in use?
Maybe you’re a Flask developer wondering why your app won’t start.
This post explains why port 5000 might be occupied and walks you through options and steps to resolve it.
It happened to me recently when I switched to a new MacBook and tried to get a Flask app running again.
When starting the app I always got the following message:
Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use
This is the machine I am working on:
- macOS Monterey Version 12.0.1
- MacBook Pro (16-inch, 2021)
- Apple M1 Max
My first action was to check what was using port 5000 by running lsof -i:5000 in the terminal.
~ % lsof -i:5000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ControlCe 20931 --------- 22u IPv4 0xa77c95dcd16d38f7 0t0 TCP *:commplex-main (LISTEN)
ControlCe 20931 --------- 23u IPv6 0xa77c95dcd16c66df 0t0 TCP *:commplex-main (LISTEN)
The result: a service named “ControlCentre” with process ID 20931 is using port 5000.
Check the resources below to read up on what the Control Centre is. Here is a quick quote from the manual:
Control Centre on Mac gives you quick access to key macOS settings—such as volume, brightness, Wi‑Fi or Focus—and indicates when your Mac is using a camera or microphone. You can customise Control Centre to add other items, such as accessibility shortcuts or Fast User switching.
If you try to kill the process with kill -9 20931, don’t bother— it restarts immediately.
There are two options:
- Use another port for your application.
- Dig a little deeper and find a specific setting.
I chose the second option and found the solution in Apple’s Developer Forum.
Under “System Preferences” select “Sharing”

In the list on the left, there is an option “AirPlay Receiver”.

Disable it.

That’s all. Now start your application that uses port 5000 and everything should run smoothly.
Of course, this solution only applies if you don’t need AirPlay Receiver.
What is an AirPlay Receiver, you ask? It’s a new feature in macOS Monterey. Here’s a quick explanation from Apple’s website:
Turn on AirPlay Receiver to receive video and audio content from any nearby Mac, iPhone or iPad on the same network.
This is actually a feature I’ve wanted for a long time, and Apple finally ships it with the new OS.
Hopefully this post saved you some time debugging and finding the right solution.
Thank you for reading!