Uploaded new Flask code, socket file disappeared, how do I bring it back?

I start this off with the fact that I am a python developer and I know very little about server management so this is all a learning curve for me.

I created a new Ubuntu 16.04 droplet and I followed this tutorial - All was well and it worked.

I used Filezilla to move my flask application from my localhost to the droplet. I overwrote the old with my was unchanged nothing else should have changed.

I ran sudo systemctl restart myproject and went to view the server from my browser and I received a 502 error.

Looking at the error log I have this:

2017/01/29 23:21:37 [crit] 18456#18456: *1 connect() to unix:/home/user/myproj/proj.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xx.xx.xx, server: xx.xx.xx.xx, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/user/myproj/proj.sock:/”, host: “xx.xx.xx.xx”

Which suggests there’s no socket file. I ran ls -al in /home/user/myproj and I can verify it’s not there. I didn’t delete it so I am not sure what happened to it and how to make it return.

I’ve verified the nginx.conf in /sites-enabled for this project and in the systemctl .service and all the info matches up.

I tried restarting/reloading my project.service, nginx and even a reboot of the server and no luck.

How do I properly return this socket file?

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.

I was following the same tutorial when myproject.sock disappeared. I am using supervisor so in myproject.ini, i set socket= an then cd /etc/nginx/sites-available, edit the myproject file. In location,

location / { include uwsgi_params; uwsgi_pass; }

Then you need to restart nginx and it should work fine

I found the solution.

My uploaded was not able to be compiled on the server due to having not (yet) installed the requirements. I used pip install from my requirements.txt, verified I could run python and when it was good to go I restarted myproject.service and the socket file was created. I could then view the app on the internet.



At first glance, the above is the key indicator. Sockets aren’t accessed over http locally, and that line seems to state that it’s attempting to do so – when it does, it fails.

Socket connects should look like:


So you’d need to find the line where the http:// is being defined and remove that.