title: Django Nginx uWSGI 502 Bad Gateway always
body: <p>I have been following the <a href="http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html" rel="nofollow">http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html</a> </p>
  
  <p>and went up to the</p>
  
  <blockquote>
    <p><a href="http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#running-the-django-application-with-uwsgi-and-nginx" rel="nofollow">http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#running-the-django-application-with-uwsgi-and-nginx</a></p>
  </blockquote>
  
  <p>and started the uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=664 it is started but when i load my webpage on browser getting <strong>502 Bad Gateway</strong> </p>
  
  <p>Django version 1.10.2</p>
  
  <p>error is </p>
  
  <blockquote>
    <p>error] 25444#25444: *1 connect() failed (111: Connection refused)
    while connecting to upstream, client: 127.0.0.1, server: mytest.com,
    request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host:
    "127.0.0.1:8000"</p>
  </blockquote>
  
  <p>What could be the issue ?</p>
  
  <pre><code># configuration of the server
  server {
      # the port your site will be served on
      listen      8000;
      # the domain name it will serve for
      server_name mytest.com; # substitute your machine's IP address or FQDN
      charset     utf-8;
  
      # max upload size
      client_max_body_size 175M;   # adjust to taste
  
      # Django media
      location /media  {
          alias /home/karesh/tutorial/uwsgi-tutorial/mysite/media;  # your Django project's media files - amend as required
      }
  
      location /static {
          alias /home/karesh/tutorial/uwsgi-tutorial/mysite/static; # your Django project's static files - amend as required
      }
  
      # Finally, send all non-media requests to the Django server.
      location / {
          uwsgi_pass  unix:/home/karesh/tutorial/uwsgi-tutorial/mysite/mysite.sock;
          include     /home/karesh/tutorial/uwsgi-tutorial/mysite/uwsgi_params; # the uwsgi_params file you installed
      }
  }
  </code></pre>
  
  <p>uwsgi_params file inside project directory</p>
  
  <pre><code>uwsgi_param  QUERY_STRING       $query_string;
  uwsgi_param  REQUEST_METHOD     $request_method;
  uwsgi_param  CONTENT_TYPE       $content_type;
  uwsgi_param  CONTENT_LENGTH     $content_length;
  
  uwsgi_param  REQUEST_URI        $request_uri;
  uwsgi_param  PATH_INFO          $document_uri;
  uwsgi_param  DOCUMENT_ROOT      $document_root;
  uwsgi_param  SERVER_PROTOCOL    $server_protocol;
  uwsgi_param  REQUEST_SCHEME     $scheme;
  uwsgi_param  HTTPS              $https if_not_empty;
  
  uwsgi_param  REMOTE_ADDR        $remote_addr;
  uwsgi_param  REMOTE_PORT        $remote_port;
  uwsgi_param  SERVER_PORT        $server_port;
  uwsgi_param  SERVER_NAME        $server_name;
  </code></pre>