title: Django with nginx connection error
body: <p>I'm just making webserver with django.</p>
  
  <p>Now, I want to publish Django by uwsgi+Nginx, So I read some documents(<a href="http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html" rel="nofollow noreferrer">http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html</a>).
  While following that doc, I met some errors.</p>
  
  <p>When I connect to mydomain.com:8000, It throws 502 Bad Gateway error.
  (Actually, when I worked, changed mydomain.com to real domain that I have)</p>
  
  <p>After error, /var/log/nginx/error.log is in below.</p>
  
  <p><code>2018/02/20 14:56:15 [error] 7548#7548: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.1.254, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "mydomain.com:8000"
  ^C</code></p>
  
  <p>This is my configure files.</p>
  
  <p>[project_rest.conf]</p>
  
  <pre><code>upstream django {
     # server unix:///path/to/your/mysite/mysite.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 8000
     # the domain name it will serve for
     server_name .mydomain.com; # 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/app/project_rest/media;
     }
  
     location /static {
         alias /home/app/project_rest/static;
     }
  
     # Finally, send all non-media requests to the Django server.
     location / {
         uwsgi_pass  django;
         include     /home/app/project_rest/uwsgi_params; # the uwsgi_params file you installed
     }
  }
  </code></pre>
  
  <p>(I made that conf file in my django project's folder and linked to /etc/nginx/sites-enabled)</p>
  
  <p>How can I connect to my server?</p>
  
  <p>I can't find where is error occured.</p>
  
  <p>Thanks.</p>