Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gunicorn: Can't connect to gunicorn.sock

I am using Django 1.8 and I want to run my application with 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 via 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 does exist, though it is empty:

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

How can I fix this?

I eventually want to run gunicorn as the user opuser, I've tried appending --user opuser --group webapps to the gunicorn command, but still get the same error.

like image 320
Richard Avatar asked Aug 23 '15 11:08

Richard


1 Answers

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

gunicorn myapp.wsgi:application --bind=unix:/webapps/myapp/run/gunicorn.sock
like image 149
henrikstroem Avatar answered Oct 12 '22 16:10

henrikstroem