Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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've setup my Python / Django app on a vmware machine with CentOS, uwsgi and gunicorn along with all my apps dependencies.

After running my app with gunicorn with the following command:

gunicorn --workers=4 --bind= wsgi:application

The application works like a charm and everything is going smoothly. However, i tried running it with uwsgi to compare performance (requests / second) on both. So i ran the following command:

sudo uwsgi --chdir=/var/www/pyapp/ --module=wsgi:application --env DJANGO_SETTINGS_MODULE=settings --socket= --processes=5  --harakiri=20  --max-requests=5000  --vacuum --master --pidfile=/tmp/

The first problem i encountered running this is the following error:

invalid request block size: 21573 (max 4096)...skip

After adding the -b 25000 to make the buffer larger than the maxmimum, i started encountering:

timeout. skip request.

I couldn't suspect that my app had something wrong with it as it ran with gunicorn without such problems.

Can someone help pointing out what i am doing here?


share|improve this question
up vote 0 down vote accepted

Adding --protocol=http solved the problem. By default uwsgi works with wsgi protocol which doesn't accept http requests.

In addition, instead of using the reverse proxy, you have to use uwsgi mode

upstream myapp {
server {
    listen 80;

    root /www/python/apps/myapp/;

    access_log /var/log/nginx/;
    error_log /var/log/nginx/;

    location /static/ {
        alias /www/python/apps/myapp/static/;
        expires 30d;

    location /media/ {
        alias /www/python/apps/myapp/media/;
        expires 30d;

    location / {
        uwsgi_pass myapp;
        include uwsgi_params;
#        proxy_pass_header Server;
#        proxy_set_header Host $http_host;
#        proxy_redirect off;
#        proxy_set_header X-Real-IP $remote_addr;
#        proxy_set_header X-Scheme $scheme;
#        proxy_connect_timeout 50;
#        proxy_read_timeout 50;
#        proxy_pass http://localhost:8081/;

    # what to serve if upstream is not available or crashes
    #error_page 500 502 503 504 /media/50x.html;
share|improve this answer
Welcome to Server Fault. If you solved this problem, please mark it as solved by clicking on the tick mark next to the answer, so that it turns green. – Michael Hampton Jul 6 '14 at 12:59

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.