title: Permission denied - nginx and uwsgi socket
body: <p>Well I am currently trying to get my django application served using nginx and uwsgi. I am currently using a virtual environment to which uwsgi is installed. However I am currently getting a 502 bad gateway error when attempting to access the page.</p>
  
  <p>The Error I am experiencing.</p>
  
  <pre><code>2014/02/27 14:20:48 [crit] 29947#0: *20 connect() to unix:///tmp/uwsgi.sock failed (13: Permission denied) while connecting to upstream, client: 144.136.65.176, server: domainname.com.au, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "www.domainname.com.au"
  </code></pre>
  
  <p>This is my nginx.conf</p>
  
  <pre><code>    # mysite_nginx.conf
  
  # the upstream component nginx needs to connect to
  upstream django {
      server unix:///tmp/uwsgi.sock; # for a file socket
      #server 127.0.0.1:8001; # for a web port socket (we'll use this first)
  }
  
  # configuration of the server
  server {
      # the port your site will be served on
      listen      80;
      # the domain name it will serve for
      server_name .domainname.com.au; # substitute your machine's IP address or FQDN
      charset     utf-8;
  
      # max upload size
      client_max_body_size 75M;   # adjust to taste
  
      # Django media
      location /media  {
          alias /home/deepc/media;  # your Django project's media files - amend as required
      }
  
      location /static {
          alias /home/deepc/static; # your Django project's static files - amend as required
      }
  
      # Finally, send all non-media requests to the Django server.
      location / {
          uwsgi_pass  django;
          include     /home/deepc/.virtualenvs/dcwebproj/dcweb/uwsgi_params; # the uwsgi_params file you installed
      }
  }
  </code></pre>
  
  <p>Here is my uwsgi.ini file</p>
  
  <pre><code>[uwsgi]
  socket=/tmp/uwsgi.sock
  chmod-socket=644
  uid = www-data
  gid = www-data
  
  chdir=/home/deepc/.virtualenvs/dcwebproj/dcweb
  module=dcweb.wsgi:application
  pidfile=/home/deepc/.virtualenvs/dcwebproj/dcweb.pid
  vacuum=true
  </code></pre>
  
  <p>From what i have read on google its a permissions problem with the www-data group and /tmp/ directory. However I am new to this and have tried to changer the permission level of the folder to no avail. Could someone point me in the right direction? Is this a permissions problem.</p>
  
  <p>Also is it ok practice to put the sock file in tmp directory?</p>
  
  <p>Thanks </p>