debugging 504 Gateway Time-out

Larry Martell larry.martell at gmail.com
Tue Aug 9 21:09:59 UTC 2016


I just set up a django site with nginx and uWSGI. Some pages I go to
work fine, but other fail with a  504 Gateway Time-out. I used to
serve this site with apache and wsgi and these same pages worked fine.

This is what I see in the nginx error log:

2016/08/09 16:40:19 [error] 17345#0: *1 upstream timed out (110:
Connection timed out) while reading response header from upstream,
client: 10.250.147.59, server: localhost, request: "GET
/report/CDSEM/MeasurementData/?group=&target_name=&recipe=&ep=&ppl=&roi_name=&lot=&date_time=8%2F1&tool_ids=23&field_1=Tool&field_2=Target&field_3=Recipe&field_4=Ep&field_5=Lot&field_6=Date+Time&field_7=Bottom&submit_preview=Generate+Report
HTTP/1.1", upstream: "uwsgi://unix:///usr/local/motor/motor.sock",
host: "xx.xx.xx.xx", referrer:
"http://xx.xx.xx.xx/report/CDSEM/MeasurementData/"

When this  happens I see this in the uwsgi error log:

Tue Aug  9 16:42:57 2016 -
uwsgi_response_writev_headers_and_body_do(): Broken pipe
[core/writer.c line 296] during GET
/report/CDSEM/MeasurementData/?group=&target_name=&recipe=&ep=&ppl=&roi_name=&lot=&date_time=8%2F1&tool_ids=23&field_1=Tool&field_2=Target&field_3=Recipe&field_4=Ep&field_5=Lot&field_6=Date+Time&field_7=Bottom&submit_preview=Generate+Report
(10.250.147.59)
IOError: write error
[pid: 9230|app: 0|req: 36/155] 10.250.147.59 () {46 vars in 1333
bytes} [Tue Aug  9 16:32:16 2016] GET
/report/CDSEM/MeasurementData/?group=&target_name=&recipe=&ep=&ppl=&roi_name=&lot=&date_time=8%2F1&tool_ids=23&field_1=Tool&field_2=Target&field_3=Recipe&field_4=Ep&field_5=Lot&field_6=Date+Time&field_7=Bottom&submit_preview=Generate+Report
=> generated 0 bytes in 640738 msecs (HTTP/1.1 200) 4 headers in 0
bytes (1 switches on core 0)

Note the weird timestamps. The first uwsgi message is more then 2
minutes after the nginx message. And the second uwsgi message has a
timestamp before the previous uwsgi message. What's up with that??

Here is my nginx config:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include            mime.types;
    default_type       application/octet-stream;
    keepalive_timeout  65;
    sendfile           on;

    # set client body size to 20M
    client_max_body_size 20M;

    include /etc/nginx/sites-enabled/*;
}


and here is my local site file:

# motor_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    server unix:///usr/local/motor/motor.sock; # for a file socket
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name localhost;
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    proxy_read_timeout 600;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    send_timeout 600;

    # Django media
    location /media  {
        alias /usr/local/motor/motor/media;
    }

    location /static {
        alias /usr/local/motor/motor/static;
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /usr/local/motor/motor/uwsgi_params;
    }
}

How can I debug or fix this?

Thanks!



More information about the nginx mailing list