[Solved]-504 Gateway Time-out uwsgi + nginx django application

23πŸ‘

βœ…

If its an internal task that takes too much time for processing, use celery to run the task.
http://docs.celeryproject.org/en/latest/userguide/tasks.html

If its not purely an internal task, eg: – uploading a large file, then increase the Nginx client_body_timeout to greater than 60s.

Its because of the default timeout in nginx config. Edit the Nginx virtual host file
and add the following line in server{} section.
http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout

# default is 60 seconds, For a 300 second timeout. 
client_body_timeout 300s;

Edit:
uwsgi_read_timeout 300s; is also needed. But its already in your config.

πŸ‘€Ryu_hayabusa

4πŸ‘

Late to the party. I spent hours configuring nginx.cfg and ended up realizing it’s related to the load balancer setting of my EC2 server. If you are using AWS Load Balancers for your EC2 server, try to also increase the Idle timeout along with the change of nginx.cfg.

πŸ‘€Zeno

1πŸ‘

My application environment is Django/Python/Nginx and it is not on AWS. I found many clues where they indicated the modification of these parameters and I applied them, but none worked for me until I tried to modify a file called "default" found in /etc/nginx/sites-available/ and added the line:
uwsgi_read_timeout 3600;

I made this modification within the location area of "listen 443", looking like this:

server { 
        listen 443 ...
        ...
        location / {
                   uwsgi_pass django;
                   ...
                   uwsgi_read_timeout 3600;
        }
        ...
πŸ‘€elhoeste

Leave a comment