Skip to content
Menu
Bashar's Blog
  • Privacy Policy
Bashar's Blog
December 21, 2022January 10, 2023

Solved: Hitting Flask Local Server on Port 5000 Returns Error 403 on Mac

After upgrading to OSX 12 or later (Monterey/Ventura) some people are facing an issue when they run Flask/Django/Laravel or any other local server on Port 5000, the server runs but it doesn’t return a proper response instead it throws an error, Error 403 which means Access Denied!

Chrome HTTP Error 403: Access to 127.0.0.1 was denied

I was a bit confused, what was wrong with my code? Even a simple “Hello World!” function is not giving me the expected response instead it was throwing HTTP error 403 and later it was throwing HTTP 404 as well. My device is MacBook Pro M1 Pro.

Chrome HTTP Error 404: This 127.0.0.1 page can’t be found

Reason Behind the Errors

The reason behind these errors I have found after doing some research was ‘AirPlay Receiver‘. AirPlay Receiver uses port 5000 to receive video or audio from other Apple Devices so when we run any local webserver or any other server in our Mac that runs OSX 12.x or later and hit the endpoints it returns us errors as it is hitting AirPlay Receiver server that was already running on port 5000, not our expected server.

Solution

For these there are two solution I have found so far:

  • Run the local development server on different port
  • Turn off the AirPlay Reciever

For the first one I ran the local development server other than port 5000, for Flask the following command run Flask server on port 5001

flask run -p 5001

It will keep both AirPlay Reciever and Flask local server on.

The other solution is turning off the AirPlay Receiver, to do that go to System Settings

Mac – System Settings

In the System Settings search bar type ‘airplay’ and you will get AirPlay Receiver in the search result. Select that and turn it off like the following image. You might asked to type the password or put touch ID for verification.

Turn off AirPlay Reciever

Now you will be able to run any server on port 5000. Watch the video if you still struggling

Bashar Bhuiyan
Bashar Bhuiyan

I am a Software Engineer, an entrepreneur, and a problem solver who loves to talk about tech, business, and side hustles. Love traveling, reading books, and trying to maintain a healthy life. To know more about me, click on the icons below

Leave a Reply Cancel reply

You must be logged in to post a comment.

Bashar's Blog © 2025