0

I have read a lot of articles about gunicorn & nginx timeout configs .

I have some requests on my website which take longer than 30 seconds . I changed all gunicorn timeouts to 3 seconds but still getting

504 gateway timeout

error after 30 seconds .

Gunicorn Config File :

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/Lav/project
ExecStart=/home/user/LavEnv/project/bin/gunicorn --access-logfile - --workers 3 --keep-alive 3 --timeout 3 --graceful-timeout 3 --bind unix:/home/user/Lav/project/project.socket project.wsgi:application

[Install]
WantedBy=multi-user.target

Nginx Config File :

server {
    listen 80;
    server_name 178.63.217.47;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root project_root;
    }
    location /media/ {
        root project_root;
    }
    location /files/ {
        root project_root;
    }


    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout   300;
        proxy_send_timeout      300;
        proxy_read_timeout      300;
        include         uwsgi_params;
        proxy_pass      http://unix:/project_root/StoreManager.socket;
    }
}

Timeouts work well when i run the website directly from gunicorn (--bind 0.0.0.0:8000) , this problem occurs with nginx-gunicorn .

How can i set timeout to a value more than 30 seconds ?

  • add inside location block `fastcgi_read_timeout 60;` http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout – num8er Apr 28 '20 at 22:32
  • fix: `proxy_pass http://unix:/project_root/StoreManager.socket;` should be: `proxy_pass unix:/project_root/StoreManager.socket;` which in Your case is: `proxy_pass unix:/home/user/Lav/project/project.socket;` – num8er Apr 28 '20 at 22:33

0 Answers0