Port 5000 already in use on Mac: check AirPlay Receiver before killing a process
Frank Zhang
- 8 minutes read - 1563 wordsTL;DR
On macOS 12 and later, AirPlay Receiver uses the TCP ports Apple lists for AirPlay: 5000, and also 6000 and 7000. Confirm the listening process read-only, then either move your app or turn the receiver off. This page is general guidance, not a record of one session.
Match the port number, see what is listening with lsof, and only then change the app port, turn off AirPlay Receiver, or stop the one process that is yours. Do not start with kill -9 on Control Center. This page is general guidance, not a record of one session. The commands were not re-run on a Mac for this page. No session on this site has this error on screen. The sources are Apple Support pages and Flask’s development-server documentation, read on 2026-11-27. If man, the wording in System Settings, or the text on the machine in front of you disagrees, that copy wins.
When a local dev server fails to start on a Mac, people often paste an English sentence like the ones below. Flask, some Node templates, and any other program told to bind port 5000 can print a close variant. Trust the command that is actually on your screen.
A common Python wording on macOS is this one (the port and path are whatever your screen shows):
OSError: [Errno 48] Address already in use
Some tools put the port in the same sentence, as port 5000 already in use, or as Address already in use followed by 5000. Node-style tools often include EADDRINUSE and the port number. The errno is often 98 on Linux and 48 on macOS; do not match on the number alone. Trust the port in the message.
So the sentence is first of all saying: the port you want to bind is already taken. On macOS 12 and later, the process that holds it is often not a Flask server you forgot to stop. It is the system’s AirPlay Receiver. This is not an SSH failure, and it is not a disk-permission problem.
Which sentences this page covers
This page is for port 5000 already in use, Address already in use, and EADDRINUSE when the port in the message is 5000. Autocomplete on 2026-11-27, en-US Google, included port 5000 already in use mac, macos port 5000 already in use, and queries about checking ports from Terminal. Bing also suggested macos control center port 5000. The same English error is what zh-CN Google completed, including port 5000 already in use mac. The root address already in use port 5000 completed in en-US Google to port 5000 is in use by another program.
This page is not about:
ssh: connect to host … port 22: Connection refusedorOperation timed out. That is remote port 22; use the connection-refused note.Operation not permittedwhen Terminal touches certain folders. That is TCC / Privacy; use the Operation not permitted note.invalid active developer pathfromgitorxcrunafter a macOS upgrade. That is the developer directory; use the xcrun note.- Windows firewall write-ups that tell you to “open port 5000”. This page is about a bind conflict on macOS for a local dev server.
If your message names port 6000 or 7000 instead of 5000, it can still be the same kind of conflict. That is covered below.
Why port 5000 is a special case on a Mac
TCP and UDP ports used by Apple software products, read on 2026-11-27, lists TCP 5000, TCP 6000, and TCP 7000 as ports used by AirPlay.
The macOS User Guide page Stream video and audio with AirPlay, read the same day, says you can use your Mac as a display or speaker for other Apple devices. The steps are: System Settings → General in the sidebar → AirDrop & Continuity, then turn on AirPlay Receiver. Change AirDrop & Continuity settings on Mac says AirPlay Receiver is available on supported Mac computers with macOS 12 or later, and that the option may be unavailable if the Mac is enrolled in MDM.
Flask’s development server documentation, also read on 2026-11-27, says flask run starts on http://localhost:5000/, and that if another program is already using port 5000 you will see an OSError with Address already in use. The same section says macOS Monterey and later automatically starts a service that uses port 5000, and that you can search for “AirPlay Receiver” in System Settings and toggle it off, or pick another port. The documented example is flask run --port 5001.
Taken together: this is not a mysterious grab of port 5000. Apple’s own port list assigns 5000 to AirPlay, and several dev tools still default to 5000. That is why the same start command can work one day and fail after a move to macOS 12 or to a new Mac. It does not prove the receiver is on for the machine in front of you. It only means see what is listening before you turn a system feature off.
Read-only: see what is listening
Read the port in the error first. If it is 5000, run the command Flask documents:
lsof -P -i :5000
-P prints numeric ports instead of service names such as commplex-main. Without -P, port 5000 can show up as commplex-main and look like a different port. It is still 5000.
To list only listening TCP sockets:
lsof -nP -iTCP:5000 -sTCP:LISTEN
If the error names 7000 or 6000, change the number in the command and look again.
Read the COMMAND, PID, and NAME columns. Trust what is on your screen. Two branches are common:
- The system branch. In a public Ask Different thread, someone on macOS 12 ran
lsof -i:5000and sawCOMMANDasControlCe(a truncatedControlCenter), with the path/System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter, listening on*:commplex-main (LISTEN). That is their example, not output this page produced on a Mac. The process name, path, and listen address on your machine are whatever your screen shows. If the path sits underControlCenter.app, treat it as AirPlay Receiver first. Do not kill it as if it were a leftover dev server. - Your own program.
COMMANDmay bePython,node,ruby, or another name you started. Flask’s ownlsofexample isPythononlocalhost:5000 (LISTEN). That branch you can stop in the terminal that launched it, or stop that PID only. Still do not kill Control Center.
If lsof prints nothing, do not conclude that nothing is using the port. Check that the port in the command matches the error, including a 7000-vs-5000 mix-up, and that the flags were copied in full. Then run it again with the port from the message.
If it is AirPlay Receiver: move the app, or turn the receiver off
Both options are valid. If you still want to AirPlay to this Mac, change the dev server’s port and leave the receiver on.
To change the port, Flask’s documented example is:
flask run --port 5001
For other tools, use that tool’s own port flag, and do not explicitly bind 5000. When you pick a new port, stay off the AirPlay TCP ports in Apple’s list: 5000, 6000, and 7000.
If you do not need this Mac to receive AirPlay, turn the receiver off and port 5000 can be free again. The official path on 2026-11-27 is:
- Open System Settings.
- Click General in the sidebar. You may need to scroll down.
- Click AirDrop & Continuity, then turn off AirPlay Receiver.
Flask’s wording is: search for “AirPlay Receiver” in System Settings and toggle it off. If your copy of System Settings does not show AirDrop & Continuity, the search box is the reliable path. Older write-ups for macOS 12 say System Preferences → Sharing. Some screens use the label AirDrop & Handoff. Trust the names on the Mac in front of you.
After you turn it off, run lsof again. If Control Center is no longer listening on 5000, start your dev server.
Changing “Allow AirPlay for” or adding a password is not the same as turning the receiver off. To free the port, either the receiver is off, or your program is on a different port.
If it is your own process: stop only that one
If lsof shows a Python, Node, or other dev process you started, stop it in the terminal where it was launched (often Control-C). Act only on that PID. Do not killall Control Center, and do not uninstall a system app because port 5000 is busy.
Run lsof once more, confirm your process is gone from that port, and then start the server again.
What not to do first
- Do not run
sudo kill -9against Control Center orControlCe. That is a system UI process. To stop its listener on 5000, use the official AirPlay Receiver switch. - Do not turn off the firewall, disable SIP, or change Privacy settings for this sentence. Those are different problems. If Terminal itself prints
Operation not permitted, read that note first. - Do not assume a different browser, or
http://127.0.0.1:5000instead oflocalhost, will dodge a bind failure. The conflict happens when the process binds the port, before a browser is involved.
Where this page stops
This page only covers a local dev server on macOS that cannot bind port 5000 (and the other AirPlay TCP ports, 6000 and 7000). It is not a guide to AirPlay picture quality, and it does not promise that other devices on the network can still play to this Mac after the receiver is off. Trust the commands and labels on your screen. If lsof shows a name that is neither Control Center nor a dev process you recognize, read its full path before you stop it, and do not reuse someone else’s PID.
If this post helps, you can sponsor the blog. This is voluntary personal support, not a charitable donation.