title: Nginx, django, gunicorn, ubuntu 14.04 (13: Permission denied) while connecting to upstream
body: <p>I am working at my <code>django</code> project with <code>nginx</code> and <code>gunicorn</code>, as it said here:</p>
  
  <p><a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04</a></p>
  
  <p>My site works locally, but when I start <code>nginx</code> and <code>gunicorn</code> server I had </p>
  
  <blockquote>
    <p>502 Bad Gateway error.</p>
  </blockquote>
  
  <p>OS is <code>UBUNTU 14.04</code></p>
  
  <p>I'm trying to make my project working,  and reinstall everything as root (I know its bad) - the same mistake.  </p>
  
  <p><strong>Here is my "error.log":</strong></p>
  
  <blockquote>
    <p>2016/04/20 20:15:10 [crit] 10119#0: *1 connect() to<br>
    unix:/root/myproject/myproject.sock failed (13: Permission denied)
    while connecting to upstream, client: 46.164.23</p>
  </blockquote>
  
  <p><strong>When i run comand "<code>nginx</code>":</strong></p>
  
  <pre><code>  nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] still could not bind()
  </code></pre>
  
  <p><strong>My gunicorn.conf</strong></p>
  
  <p><code>description "Gunicorn application server handling myproject"
  start on runlevel [2345]
  stop on runlevel [!2345]
  respawn
  setuid root
  setgid www-data
  chdir /root/myproject
  exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application</code></p>
  
  <p><strong>Thats my "/etc/nginx/sites-available/myproject"</strong></p>
  
  <pre><code>server {
  listen 80;
  server_name         www.mysite.ru;
  
  error_log /nginx_error.log;
  
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
      root /root/myproject;
  }
  
  location / {
      include proxy_params;
      proxy_pass http://unix:/root/myproject/myproject.sock;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I will appreciate your help very much!!!</p>