meinheld icon indicating copy to clipboard operation
meinheld copied to clipboard

File upload fails with 502

Open keremnymn opened this issue 3 years ago • 7 comments

I am using Gunicorn + Flask + Meinheld + NGINX with egg:meinheld#gunicorn_worker setting but when I try to upload more than 10 MB server fails with 502 Bad Gateway. I think Meinheld causes the issue because I can upload the same files with sync workers.

Exact error is:

[error] 4338#4338: *1 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 127.0.0.1, server: localhost, request: "POST /******** HTTP/1.1", upstream: "http://127.0.0.1:8000/*********", host: "localhost", referrer: "http://localhost/******/"

Edit: When I disable Gunicorn and use only Meinheld, it works without an error.

Any ideas?

keremnymn avatar Sep 27 '21 20:09 keremnymn

hi @keremnymn

Could you please show me each middleware settings? (nginx, gunicorn and so

soundkitchen avatar Oct 05 '21 04:10 soundkitchen

Gunicorn: gunicorn --workers=6 --worker-class="egg:meinheld#gunicorn_worker" app:app app.py:

import meinheld, os
from **** import create_app

app = create_app()

if __name__ == "__main__":
    if os.environ['RUNNING_ON'] == 'localhost':
        app.run(debug=True)
    else:
        meinheld.listen(("0.0.0.0", 5000))
        meinheld.run(app)

nginx:

server {
        listen 80;
        server_name localhost;
        client_max_body_size 512M;

        location /static {
                alias /********/static;
        }
        location / {
                proxy_pass http://localhost:8000;
                include /etc/nginx/proxy_params;
        }
}

keremnymn avatar Oct 05 '21 06:10 keremnymn

any updates about this issue?

zulfirman avatar Aug 16 '22 07:08 zulfirman

I solve it by changing to gevent, I use gunicorn with meinheld before but now using gunicorn with gevent.

gunicorn --bind=0.0.0.0:5000 -w 3 --worker-class=gevent app:app --timeout 60

zulfirman avatar Aug 18 '22 03:08 zulfirman

I had the same problem

jet10000 avatar Oct 28 '22 16:10 jet10000

caddy -> gunicorn(meinheld) -> django

gunicorn --workers=5 --worker-class="egg:meinheld#gunicorn_worker" --bind :8000 myproject.wsgi

When upload 3M image file via form, it's display Request timeout, Then I just use gunicorn

caddy -> gunicorn -> django

gunicorn --workers=5 --bind :8000 myproject.wsgi

It's working.

@jet10000

https://m.xkcd.com/979/

jet10000 avatar Oct 28 '22 16:10 jet10000