0

I'm trying to deploy a flask project (uwsgi + Nginx) on ubuntu 20.04 server. For this I'm following Digital Ocean.

I get 502 bad gateway nginx/1.18.0 (Ubuntu) error.

After checking nginx error logs I find

 upstream prematurely closed connection while reading response header from upstream, client: 93.37.157.148, server: 3.75.132.146, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/ubuntu/flask-app/webapp/flask-app.sock:", host: "3.75.132.146", referrer: "http://3.75.132.146/"

My .ini file includes:

[uwsgi]
module = wsgi:app
wsgi-file = /home/ubuntu/flask-app/webapp/wsgi.py
chdir = /home/ubuntu/flask-app/webapp/
protocol = http
#home = /usr/local/lib/python3.8/dist-packages/

master = true
processes = 5

limit-as = 512
uid = ubuntu
gid = www-data
socket = flask-app.sock

chown-socket = ubuntu
chmod-socket = 777
vacuum = true

die-on-term = true

And my nginx config files includes:

server {
    listen 80;
    server_name 3.75.132.146;

    location /static {
        alias /home/ubuntu/flask-app/webapp/static/;
    }
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/ubuntu/flask-app/webapp/flask-app.sock;
    }
}

I have been searching online and no one seems to have a solid solution for this. Please help me if anyone already faced this and solved this issue.

Thanks

1 Answers1

0

Try to delete 'protocol = http' from My.ini and add 'socket-timeout=36000'

Kaison L
  • 86
  • 5