bad gateway flask nginx uwsgi

I’m trying to expand from a basic one file flask app and restructure into a proper application. I followed and initial set up on a digital ocean server from a tutorial I found here:

Then I tried to restructure the application following this tutorial:

I am getting a 502 bad gateway error.

my current folder structure is as follows:

       |      |
       |      |--
       |      |__

content of files:

from flask import Flask
app = Flask(__name__)

from app import views
content of

from app import app

def index():
    return "Hello world"

def about():
    return "All about Flask"

content of sieroApp.ini:

module = wsgi:app

master = true
processes = 5

socket = sieroApp.sock
chmod-socket = 660
vacuum = true

die-on-term = true

content of

from sieroApp import app

if __name__ == "__main__":

content of etc/systemd/system/sieroApp.service:

Description=uWSGI instance to serve sieroApp

ExecStart=/home/max/sieroApp/sieroAppenv/bin/uwsgi --ini sieroApp.ini


content of etc/nginx/sites-available/sieroApp:

    server {
        listen 80;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/max/sieroApp/sieroApp/sieroApp.sock;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @eventhorizon02,

I can’t see any issues with the files you’ve provided. Having said that, the issue might be somewhere else, what does your Nginx error_log say?

Usually, when you are not sure what exactly the error is and you are seeing something generic like 502 Bad Gateway, the best option is always to go and check the the service’s error log. Regarding Nginx, you should be able to see the log at /var/log/.

Please check it there and see if you can further troubleshoot your application. If you are not sure how to continue, post the error here and we’ll try to help out!

Regards, KFSys