[Fixed]-What is gunicorn.sock?


You’re supposed to use a reverse proxy like nginx to sit in front of gunicorn, and that’s what actually serves your site. They communicate via the socket.

The gunicorn docs have a sample nginx configuration which does exactly that, although obviously you should make the sockfile match what you’ve put in your gunicorn config.


Sockets are a much faster, more efficient alternative to network ports if you are working locally on a server. However if your nginx server and your django app are on different servers then your would need to open up specific ip connections.

For your example if you want to use sockets you just need to point the upstream server address to your socket file.
Change the nginx configuration as

upstream hello_app_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
    server unix:/var/www/testapp/run/gunicorn.sock fail_timeout=0;

server {
    # Rest of your file...

Leave a comment