Ngnix not forwarding request to gunicorn socket.

Posted September 11, 2019 2.5k views
NginxCentOSPythonPython Frameworks

I’ve was following This article of digital ocean

I was able to setup flask, gunicorn, Nginx correctly but any request to my server Nginx routes to default Nginx home page rather forwarding to my app. It’s been three days since I am debugging this but not able to solve this.

Some difference between my setup vs this article mentions is,

  1. Instead of server name I’ve used my server public gateway address
  2. I am using Centos 7 rather ubuntu 18.04
    3 I am using group 1000 instead of www-data.

rest is same. Its not showing any error also so I am not sure what is happening, any help is welcomed

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.

2 answers

Hi :)

First off, good job on getting this far. Just FYI, many of the more popular tutorials have versions for different platforms, eg, there is a version of that tutorial for Centos 7 here:

OK, so in the nginx config, for server_name you put your public Droplet IP? That’s in this section of the tutorial,

At the end of that section there’s a couple of commands to start and enable this config - were you able to run those? If nginx is already running, you may need to restart it like:

sudo systemctl restart nginx

Hope this helps, let us know how it goes.

by Justin Ellingwood
In this guide, we will be setting up a simple Python application using the Flask micro-framework on CentOS 7. The bulk of this article will be about how to set up the Gunicorn application server to launch the application and Nginx to act as a front end reverse proxy.

Saw in another place an answer that MAY help - not sure. In Django, there’s a ALLOWED_HOSTS configuration parameter which needs to have the domain name. I’m not sure if Flask has that or not - apologies. If it does, check that out.

Submit an Answer