17

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!

Leachy Peachy
  • 1,112
  • 2
  • 17
  • 29
  • Add config for uWSGI. I think problem with path here `uwsgi_pass unix:///home/mysite/public/myapp.sock;` – b1_ Jul 18 '12 at 05:26

2 Answers2

24

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).

freb
  • 1,151
  • 13
  • 28
  • To clarify, you need to add `uwsgi_read_timeout 600;` inside corresponding `location` section. – serg Dec 22 '15 at 17:42
  • Man, ... I was banging my head for 3 hours, trying to set any parameter in nginx. Thx! – rkj Jan 11 '17 at 15:30
-1

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

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

raidsan
  • 777
  • 1
  • 7
  • 11