Flask error handlers not registered when defined in non-imported module with Gunicorn
warningconfigurationUpdated Mar 24, 2026
How to detect:
When running a Dash/Flask application with Gunicorn, custom Flask error handlers (@server.errorhandler) are not invoked if they are defined in a module that is not imported by the module specified in the Gunicorn command. The server object passed to Gunicorn must already have error handlers registered at import time.
Recommended action:
Ensure error handlers are registered in the same module that exports the server object being passed to Gunicorn (e.g., if running 'gunicorn index:server', define error handlers in index.py), or ensure the module containing error handlers is imported before the server object is exported. Verify the module initialization order matches the Gunicorn target.