Gunicorn: Can't connect to gunicorn.sock

I am using Django 1.8 and I want to run the application using gunicorn.

I can run it OK from the command line binding to my IP:

gunicorn myapp.wsgi:application --bind xx.xx.xx.xx:8001 

But now I want to run it through a Unix socket:

 gunicorn myapp.wsgi:application --bind=unix$/webapps/myapp/run/gunicorn.sock 

I get this error:

 [2015-08-23 07:38:04 +0000] [18598] [INFO] Starting gunicorn 19.3.0 [2015-08-23 07:38:04 +0000] [18598] [ERROR] Retrying in 1 second. [2015-08-23 07:38:05 +0000] [18598] [ERROR] Retrying in 1 second. [2015-08-23 07:38:06 +0000] [18598] [ERROR] Retrying in 1 second. [2015-08-23 07:38:07 +0000] [18598] [ERROR] Retrying in 1 second. [2015-08-23 07:38:08 +0000] [18598] [ERROR] Retrying in 1 second. [2015-08-23 07:38:09 +0000] [18598] [ERROR] Can't connect to $/webapps/myapp/run/gunicorn.sock 

If I do ls -al /webapps/myapp/run , I see that the socket file exists, although it is empty:

 srwxrwxrwx 1 opuser webapps 0 Aug 23 07:22 /webapps/myapp/run/gunicorn.sock 

How can i fix this?

Ultimately, I want to run gunicorn as an opuser user, I tried adding --user opuser --group webapps to the gunicorn command, but still getting the same error.

+6
django sockets gunicorn
source share
3 answers

According to the documentation ( http://gunicorn-docs.readthedocs.org/en/latest/run.html ), you should use: unix:$(PATH) , i.e. your command should read:

 gunicorn myapp.wsgi:application --bind=unix:/webapps/myapp/run/gunicorn.sock 
+5
source share

remove venv/run and then mkdir run without using sudo

0
source share

Just use the following command without double quotes: "gunicorn appname.wsgi". Make sure you run this command where your wsgi.py is located.

-3
source share

All Articles