Getting "502 Bad Gateway" with nginx, uwsgi python-flask on ubuntu 16.04 Getting "502 Bad Gateway" with nginx, uwsgi python-flask on ubuntu 16.04 flask flask

Getting "502 Bad Gateway" with nginx, uwsgi python-flask on ubuntu 16.04


I had the same problem using the guide. As far as I've read; 502 bad gateway is a symptom of Nginx not being able to properly connect to the uwsgi. Changing the permissions on the socket solved the issue for me.

sudo chmod 777 /home/sajjan/project/project.socksudo systemctl restart nginx

777 is offcourse a bit excessive, but its a quick and dirty way to verify if it is in fact a problem with permissions


Nginx has no permission to write to socket. Granting appropriate mode with below command, helped me.

chmod 0755 /to/project


Same problem.

But I give the 666 permission and restart all, and it works.

I think the error log only show the problem's one possible cause. While, the journalctl -u <yourproject>.service command help present another reason.

My error log also tells me that he can't find the "myproject.socket". But .ini has already help us build it. Then I get this error: myproject.service: Failed at step USER spawning ~/bin/uwsgi: No such process

So maybe it is the permission's problem.