How to resolve the gunicorn critical worker timeout error?

To fix this increase the timeout flag in Nginx,

In Nginx increase proxy_connect_timeout and proxy_read_timeout, you can add the following in nginx.conf file under the http directive. They default to 60s.

proxy_connect_timeout 300s;

proxy_read_timeout 300s;

Restart Nginx server. See nginx docs on timeouts.

If above fix doesn’t work, then increase Gunicorn timeout flag in Gunicorn configuration, default Gunicorn timeout is 30 seconds.

–timeout 90

Gunicorn documentation about timeout

-t INT, –timeout INT
30
Workers silent for more than this many seconds are killed and restarted.

Generally set to thirty seconds. Only set this noticeably higher if you’re sure of the repercussions for sync workers. For the non sync workers it just means that the worker process is still communicating and is not tied to the length of time required to handle a single request.

Gunicorn Docs on Worker Timeouts

Hope this solves it.

Leave a Comment