Flask App wsgi nginx error : permission denied while connecting to upstream

I’m getting a 502 bad gateway on nginx, and the following on the logs: connect() to …myproject.sock failed (No such directory or file /home/nickname/myproject/myproject.sock) while connecting to upstream. Although I went to create the file “myproject.sock” in the myproject directory which gives me (13: Permission denied) error.

My working dir (myproject) is in /home/nickname dir. And I also created myprojectenv in the /home/nickname directory as well, making it 2 directory in the /home/nickname

Also the chmod-socket was 660 but I changed it to 666 thinking it was a privileges issue, but I still have an error 502.


module = wsgi:app

master = true
processes = 5

socket = myproject.sock
chmod-socket = 666
vacuum = true

die-on-term = true


Description=uWSGI instance to serve myproject

ExecStart=/home/nickname/myprojectenv/bin/uwsgi --ini myproject.ini



server {
    listen 80;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/nickname/myproject/myproject.sock;

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.

ugh me too. My only deviation from the tutorial was to put the folder in the “shared” directory.

I assume you followed the DigitalOcean tutorial “How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04”. It seems like few few people are running into the same issue. Take a look at this answer: