title: failed (22: Invalid argument) while connecting to upstream
body: <p>I am following a tuturial to get a new Django website online but I keep getting a 502 Bad Gateway error. </p>
  
  <p>When checking the error log I see this message keep coming back:  </p>
  
  <p>When I enter gezelligehotelletjes.com:8000</p>
  
  <pre><code>2015/12/20 13:47:02 [crit] 2194#0: *3 connect() to 0.0.31.65:80 failed (22: Invalid argument) while connecting to upstream, client: 95.96.206.181, server: 45.79.160.100, request: "GET / HTTP/1.1", upstream: "uwsg$ "uwsgi://0.0.31.65:80", host: "www.gezelligehotelletjes.com:8000"
  </code></pre>
  
  <p>And when I enter the IP address: 45.79.160.100</p>
  
  <pre><code>2015/12/20 13:48:32 [crit] 2194#0: *6 connect() to 0.0.31.65:80 failed (22: Invalid argument) while connecting to upstream, client: 95.96.206.181, server: 45.79.160.100, request: "GET / HTTP/1.1", upstream: "uwsg$ "uwsgi://0.0.31.65:80", host: "45.79.160.100:8000"
  </code></pre>
  
  <p>This is the project tree I am currently working with:</p>
  
  <pre><code>.
  ├── db.sqlite3
  ├── manage.py
  ├── mysite
  │   ├── __init__.py
  │   ├── media
  │   │   └── media.png
  │   ├── __pycache__
  │   │   ├── __init__.cpython-34.pyc
  │   │   ├── settings.cpython-34.pyc
  │   │   ├── urls.cpython-34.pyc
  │   │   └── wsgi.cpython-34.pyc
  │   ├── settings.py
  │   ├── static
  │   ├── urls.py
  │   ├── uwsgi_params
  │   └── wsgi.py
  ├── mysite_nginx.conf
  ├── mysite.sock
  ├── static
  │   └── admin
  │       ├── css
  │       │   ├── base.css
  │       ├── fonts
  │       │   ├── README.txt
  │       ├── img
  │       │   ├── calendar-icons.svg
  │       └── js
  │           ├── actions.js
  └── test.py
  </code></pre>
  
  <p>Currently I am not using the socket, but for now I have created an empty file "mysite.sock" in the root directory. </p>
  
  <p>These are the contents of mysite_nginx.conf:</p>
  
  <pre><code># mysite_nginx.conf
  
  # the upstream component nginx needs to connect to
  upstream django {
      server unix:///path/to/your/mysite/mysite.sock; # for a file socket
      # server localhost: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 gezelligehotelletjes.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/johan/gezelligehotelletjes/gezelligehotelletjes/media;  # your Django project's media files - amend as required
      }
  
      location /static {
          alias /home/johan/gezelligehotelletjes/gezelligehotelletjes/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/johan/gezelligehotelletjes/gezelligehotelletjes/uwsgi_params; # the uwsgi_params file you installed
      }
  }
  </code></pre>
  
  <p>And the contents of uwsgi_params:</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>
  
  <p>I read I only had to copy and paste this into this file, but maybe this needs to be changed as well. </p>
  
  <p>When I visit gezelligehotelletjes.com or 45.79.160.100 I get to see the "Welcome to NGinx" page.</p>
  
  <p>The server is running on Ubuntu 14.04 LTS and I am using a virtualenv. </p>
  
  <p>I have been looking around on the web for proper solutions but I have not been able to figure it out yet after working on it for the last couple of days. 
  I really hope someone can help me out here. </p>
  
  <p>Thanks in advance. </p>