How to solve 403 error with Flask in Python?

Mac OSX Monterey (12.x) currently uses ports 5000 and 7000 for its Control centre hence the issue.

Try running your app from port other than 5000 and 7000

use this:

if __name__ == "__main__":
    app.run(port=8000, debug=True)

and then run your flask file, eg: app.py

python app.py

You can also run using the flask command line interface using this command provided you have set the environment variable necessary for flask CLI.

flask run --port 8000

You can also turn off AirPlay Receiver in the Sharing via System Preference.

Related discussion here: https://developer.apple.com/forums/thread/682332

Update(November 2022):

Mac OSX Ventura(13.x) still has this problem and is fixed with the change in default port as mentioned above.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)