Django+Nginx+uWSGI = 504 Gateway Time-out

孤街醉人 提交于 2021-02-06 10:01:36

问题


I am running Ubuntu 10.04, Django 1.3, Nginx 0.8.54 and uWSGI 0.9.7.

Both Nginx and uWSGI load without error. However, when you access my site, it sits for a LONG time and then eventually loads a "504 Gateway Time-out" error.

Here is my Nginx Virtual Host conf file:

server {
listen          80;
server_name     www.mysite.com mysite.com;
error_log       /home/mysite/log/error.log;
access_log      /home/mysite/log/access.log;

location / {
    auth_basic  "Restricted";
    auth_basic_user_file    /home/mysite/public/passwd;
    include uwsgi_params;
    uwsgi_pass unix:///home/mysite/public/myapp.sock;
}

location /media {
    alias /home/mysite/public/myapp/media;
}


error_page  401  /coming_soon.html;

location /coming_soon.html {
    root /home/mysite/public/error_pages/401;
}

location /401/images {
    alias /home/mysite/public/error_pages/401/images;
}

location /401/style {
    alias /home/mysite/public/error_pages/401/style;
}

}

My site log shows this:

SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / !!!

My error log show this:

upstream timed out (110: Connection timed out) while reading response header from upstream

I have two other sites on this server with the same configuration and they load PERFECTLY.

Has anyone else encountered this problem? There are several threads on here that are similar to my issue and I've tried several of those solutions but nothing seems to work.

Thank you in advance for your help!


回答1:


That error is produced when requests exceed the NGINX uwsgi_read_timeout setting. After NGINX exceeds this limit it closes the socket and then uWSGI tries to write to the closed socket, producing the error that you see from uWSIG.

Make sure your NGINX timeouts are at least as high as uWSGI timeouts (HARAKIRI_TIMEOUT).




回答2:


unix:///home/mysite/public/myapp.sock; syntax not correct, use like this:

unix:/home/mysite/public/myapp.sock;



来源:https://stackoverflow.com/questions/6672073/djangonginxuwsgi-504-gateway-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!