My Flask app runs through uWSGI, and I am using a TCP socket to talk to NGINX. The configuration is very basic:


server {
    listen 80 default_server;

    location / {
        include uwsgi_params;

I specify the TCP socket in my .ini:


socket =

# remove the socket once disconnected
vacuum = true

module = wsgi
callable = app
processes = 4
threads = 2
master = 1

And my module:


from app import create_app

app = create_app('config/development.py')

if __name__ == '__main__':
    app.run() only returns 404 errors (and NGINX 502 errors when uWSGI is not running).

How can I get uWSGI and NGINX to speak to one another? How can uWSGI serve the Flask app through NGINX?

  • 1
    Check your error log. – Michael Hampton Feb 13 '17 at 18:43
  • error.log gives me: [notice] 4xxxx#0: signal process started – llater Feb 14 '17 at 1:16
  • 1
    I solved the problem by setting the Flask config "SERVER_NAME" to a domain configured in my OS X host file "applicationlocal", and then changed my application.conf to: listen 80; server_name applicationlocal. Hope this helps someone! – llater Feb 14 '17 at 3:21
  • 1
    @LelandLater Please write it as an answer, even if it's ur own question. – Piotr Dawidiuk Feb 14 '17 at 14:07

I solved the problem by changing my Flask configuration to specify the server:


SERVER_NAME = 'applicationlocal'

and then specified that server in the NGINX configuration:


location / {
     listen 80;
     server_name applicationlocal;

I had previously edited the OS X host file to match to "applicationlocal"; now I can access the application at "applicationlocal:80/" but not "".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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