serving flask app using gunicorn + nginx showing 404 [ec2] serving flask app using gunicorn + nginx showing 404 [ec2] nginx nginx

serving flask app using gunicorn + nginx showing 404 [ec2]


Did you do nginx -s reload && systemctl restart nginx?

Another thing which you could try is to make the bindings on a http port instead of a socket:

--bind 127.0.0.1:6767 #in systemd config

and change nginx config as follows:

location / {    include proxy_params;    proxy_redirect off;    proxy_pass http://127.0.0.1:6767;}

Also why do you have private_ip in nginx config?

server_name private_ip_address;

Change that to

server_name "_";# ORserver_name PUBLIC_IP;

and remove all default configs from /etc/nginx/site-enabled


1) use of server_name private_ip_address;?

Nginx uses the server_name to check with the host header of the incoming request, and that isn't the private address. (You usually access using either a domain name or the public address in the URL bar)

2) I deleted /etc/nginx/site-enabled/default dir to make things to get to working.

If your server_name is not set correctly, nginx processes the request using the default file or the server block containing default_server. Thus I asked you to delete that file just in case there was an issue with your server name ^_^

Also, what difference would it make to the performance of the API if I am binding it to a port instead of the socket file as suggested by the blog post?

This would typically be premature optimization, any difference you get will purely be within a margin of error compared to the bottlenecks caused by flask/python and especially database connections. Though please take this with a grain of salt as I do not have any reliable source to quote this on.