Flask request timeouts

Hi,

I am using python flask api to extract data from database. Sometimes based on data, query takes more than 30 seconds, but flask api is getting timeouts in 30 seconds by default.

Is there any way to increase request timeouts in Flask. Please share references.

Thank you!

I think the timeout is to be set in the web server layer, like gunicorn or uwsgi.
Check out this same question: How to set connection read timeout and support flask run in multi-thread mode? · Issue #2351 · pallets/flask · GitHub

Also, instead of making long-running query in the view/request handler, you may want to have it processed in the background, for example by using a task queue like celery.
https://flask.palletsprojects.com/en/2.0.x/patterns/celery/

Thanks Mariatta for your response.

I am using cloud server to deploy. Indeed it was timing out at cloud server (route) layer. I was able to update timeout under cloud server route configurations.