Question

Ngnix not forwarding request to gunicorn socket.

I’ve was following This article of digital ocean https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

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


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.

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.

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:

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7

OK, so in the nginx config, for server_name you put your public Droplet IP? That’s in this section of the tutorial, https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7#configuring-nginx-to-proxy-requests.

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.