Gunicorn.sock files : How are they generated? Where should they be located?

Posted February 26, 2015 18.4k views

Hi I’m currently trying to follow a tutorial on installing nginx with gunicorn and django. I’ve combed the web for more docs/explanation on the gunicorn.sock file, it’s contents and location.

So far all the tutorials I’ve seen include such a file, but do not explain fully their purpose. Can anyone on digital ocean shed more light on these? I’ve done a search for ‘gunicorn.sock’ on but I get the boilerplate 'Your search did not match any documents…’

Thanks in advance :-)

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.

5 answers

you can specify the sock file you want to create with –bind flag in gunicorn --bind unix:/home/youusername/somename.sock.

In nginx you can do.

location /home/ {
        proxy_pass http://unix:/home/youusername/somename.sock;

Hi, Sock files are Unix domain sockets that processes use to communicate - in this case, Gunicorn uses its .sock files to talks to other parts of the process.

I have the same question RE *.sock files, how are they created?

The documentation here ( says you can use in terminal:


And also in the nginx config file in /etc/nginx/sites-available/whatever you called your config file
(also symlinked to sites-enabled)

But this didn’t answer my question/solve my bad gateway error.

yeah i’ve had the same questions for awhile now as well. Several tutorials on deploying django, gunicorn and nginx talk about daemonizing/automating gunicorn but in the conf files, it specifies a .sock file. where is this .sock file? is it usually created automatically by whichever WSGI you choose i.e uWSGI, gunicorn? i tried to find the .sock file for my respective django app on ubuntu using find command but no luck. i want to use supervisor to automate gunicorn but i dont fully understand the conf file for superviser.

If i am running gunicorn +django app inside a docker container how will i specify this http://unix:/home/youusername/somename.sock;

Submit an Answer