Overview
MacOS Monterey (version 12) is the 18th and current major release of macOS. The successor to macOS Big Sur, it was announced at WWDC 2021 on June 7, 2021, and was officially released on October 25, 2021. Every update of Macintosh comes with some surprises and nightmares(this time address already in use).
In this blog, I’m not talking about all the good thing that has been introduced in the new release but will be talking about one thing that is super annoying for every developer. This new version of macOS has “hijacked our cute little port — 5000” from us.
5000 port already in use by MacOS
Yeah you heard this right, from ages developers are using this 5000 port for local development and now it’s like a default thing for any local server. You’ll get an error as below. As of macOS ControlCe service is listening of the port.
OSError: [Errno 48] Address already in use
Issue
Run a Flask server or any server of your choice
Run the simple flask server using
python app.py
Then you must be seeing something like below
File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 48] Address already in use
This error is coming because the port that we are using for the local server is actually in use by MacOS
Solution
Simple solution is just use some other port instead of 5000 or else follow the below steps.
Step 1
Open system preferences
Step 2
Then open Sharing
Step 3
Uncheck Airplay Receiver, as Airplay receiver is using that port
Run the server again!!
Conclusion
I hope, it has helped you. If you want to discuss anything or anything related to tech, you can contact me here or on my personal blog Progress Story. See you next time. Peace out!
very useful, thank you. I am getting the following message (trying to start a docker container):
Bind for 0.0.0.0:5000 failed: port is already allocated
Thanks for the comment. I guess this will not come after you disable the airplay receiver.