Question

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

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 docs.gunicorn.org but I get the boilerplate ‘Your search did not match any documents…’

Thanks in advance :-)


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 have the same question RE *.sock files, how are they created?

The documentation here (https://docs.gunicorn.org/en/stable/run.html?highlight=bind) says you can use in terminal:

GUNICORN_CMD_ARGS="unix:$HOME/somedir/appname.sock"

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.

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

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;
    }