Flask Config File – ‘DEBUG=True’ Do Nothing

Running with the debugger is different than setting the DEBUG config. You have to do both. Running the server in debug mode sets the config automatically. Typically, you should rely on that rather than setting the config directly.

The “correct way to configure” you read about is a) just another way, not the “correct” way, and b) only sets the config, not the FLASK_DEBUG environment variable, which is what controls the debug mode for the server.

Setting the environment variable FLASK_DEBUG=1, or passing the --debug option to the flask command as of Flask 2.2, tells flask run to wrap the application with the debugger and reloader. (app.run(debug=True) does the same, but the flask run command is preferred). app.debug switches some internal behavior in the Flask app, such as passing through errors to the interactive debugger that development mode enabled.

Leave a Comment