Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a database-backed web site that receives very little traffic. However, once or twice day, a request will timeout and I'll see this (or a similar) error in Nginx's error.log:

2013/06/13 18:32:40 [error] 16723#0: *27796 upstream timed out (110: Connection timed out)
while reading response header from upstream, client:, server:, request: "POST /api?submit_staker_response HTTP/1.1", upstream:
"uwsgi://unix:/var/run/uwsgi/", host:
"", referrer:

I'm running uWSGI and there's nothing related to this at all (that I can tell) in its log file. I suspected it might be PostgreSQL related, but if I check its status via pg_stat_activity I see nothing out of the ordinary.

This is my uWSGI YAML config file:

    socket: /var/run/uwsgi/%n-uwsgi.sock
    workers: 5
    buffer-size: 32768
    callable: app
    wsgi-file: /opt/sites/
    virtualenv: /opt/virtualenv/
    pythonpath: /opt/sites/

The server I'm on has two (virtualized) cores, so I did 1 + cores*2 to determine the number of workers. I also upped the buffer-size parameter to try to fix this but the error still occurs.

I'm not sure where to begin to debug this. I have little experience running uWSGI (or any Python WSGI implementation).

share|improve this question
I had the exact same problem yesterday, my problem was that on the uWSGI server I was out of file descriptors and Cassandra read latency was high and apparently uWSGI was closing the socket after waiting for the data. This might be a fair point to start. – APZ Jun 14 '13 at 23:27

The option triggering the timeout (in nginx) is

its default is 60 seconds, so if you request does not generate output in that timeslice nginx will close the connection.

If you do not see error in uWSGI (a part i suppose from the "broken pipe" as nginx disconnected) i would investigate why the generation is so slow

share|improve this answer
I can't replicate this on my local computer, and I don't want to profile production requests. How would you investigate why the generation is so slow? Should I profile the requests? – skyler Jun 17 '13 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.