title: Gunicorn Socket file is missing
body: <p>I am running a Django project and I want Gunicorn and Nginx to serve this project.
  I am using Gunicorn 19.5.</p>
  
  <p>The problem is basically that my socket file doesn't get created and I tried everything (chmod 777, chown, ...) and nothing is working.</p>
  
  <p>Here is my bash script to start gunicorn:</p>
  
  <pre><code>#!/bin/bash
  NAME="hello_project" # Name of the application
  DJANGODIR=/home/ubuntu/git/hello_project # Django project directory
  SOCKFILE=/home/ubuntu/git/hello_project/run/gunicorn.sock # we will communicte using this unix socket
  LOG_FILE=/home/ubuntu/git/hello_project/logs/gunicorn.log
  
  USER=ubuntu # the user to run as
  GROUP=ubuntu # the group to run as
  NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
  
  MAX_REQUESTS=1 # reload the application server for each request
  DJANGO_SETTINGS_MODULE=hello_project.settings # which settings file should Django use
  DJANGO_WSGI_MODULE=hello_project.wsgi # WSGI module name
  
  echo "Starting $NAME as `whoami`"
  
  # Activate the virtual environment
  cd $DJANGODIR
  source ~/.virtualenvs/hello_project/bin/activate
  
  export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
  export PYTHONPATH=$DJANGODIR:$PYTHONPATH
  
  # Create the run directory if it doesn’t exist
  RUNDIR=$(dirname $SOCKFILE)
  test -d $RUNDIR || mkdir -p $RUNDIR
  
  # Start your Django Unicorn
  
  # Programs meant to be run under supervisor should not daemonize themselves (do not use –daemon)
  exec ~/.virtualenvs/hello_project/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  –name $NAME \
  –workers $NUM_WORKERS \
  –max-requests $MAX_REQUESTS \
  –user=$USER –group=$GROUP \
  –bind=unix:$SOCKFILE \
  –log-level=debug \
  –log-file=$LOG_FILE
  </code></pre>
  
  <p>I am getting crazy here, there is no log file where I can look at, I even tried to create the socket file myself with no success. I suspect it's a permission problem but even when I run the script with sudo, it doesn't work.
  My directory "run" gets created though.</p>
  
  <p>Here is the nginx error from the error.log file: </p>
  
  <pre><code>2016/05/19 16:56:32 [crit] 11053#0: *28 connect() to unix:/home/ubuntu/git/hello_project/run/gunicorn.sock failed (2: No such file or directory) while connecting to upstream...
  </code></pre>
  
  <p>Any clue ?</p>
  
  <p>Thanks a lot,</p>