django gunicorn and nginx proxy giving 502 error
I went through all the related questions and could not find the answer, i went through the docs as well and tried all that i could, its my first time, hence having a hard time. 
I have a simple `django polls app`  with proper settings and static files, working locally. 

As mentioned in the title i am trying to use django on a newly bought VPS, with nginx and gunicorn, i am using virtualenv as well.  
 
Here is my folder structure on the server:
`logs`  `pid`  `projhome`  `scripts`

inside the projhome i have the following directories:
`bin`  `djangopolls`  `include`  `lib`  `local`

inside the `djangopolls` project i have all django files(manage/settings/apps etc.) and an extra `gunicorn_cfg.py` with the following content:


    import os
    user_home = os.environ["HOME"]
    bind = "127.0.0.1:8000"
    workers = 3
    max_requests = 500
    debug = False
    daemon = True
    pidfile = os.path.join(user_home, "pid/gunicorn.pid")


as already mentioned parallel to the projhome folder i have scripts folder, with the following content:

    source /home/django/projhq/bin/activate
    kill `cat /home/username/pid/gunicorn.pid`
    gunicorn_django -c /home/username/projhome/djangopolls/gunicorn_cfg.py


and in the `/etc/nginx/sites-enabled` i made a file mynginx.conf with following content:


    server {
        listen 80;
        root /home/django/projhq/djpolls;
    
        access_log /var/log/nginx/djpolls_access.log;
        error_log  /var/log/nginx/djpolls_error.log;
    
    location /static {
            root /home/username/projhome/djangopolls/static_media;
        }
        location / {
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   REMOTE_HOST      $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   X-FORWARDED-PROTOCOL $scheme;
            proxy_pass http://127.0.0.1:8000;
        }
    }

Now to start the server i need to go to the scripts folder and run the start script, i do that without any error, but when i check the `IP` i get 502 error. 


Where am i wrong???
django gunicorn and nginx proxy giving 502 error
===

I went through all the related questions and could not find the answer, i went through the docs as well and tried all that i could, its my first time, hence having a hard time. 
I have a simple `django polls app`  with proper settings and static files, working locally. 

As mentioned in the title i am trying to use django on a newly bought VPS, with nginx and gunicorn, i am using virtualenv as well.  
 
Here is my folder structure on the server:
`logs`  `pid`  `projhome`  `scripts`

inside the projhome i have the following directories:
`bin`  `djangopolls`  `include`  `lib`  `local`

inside the `djangopolls` project i have all django files(manage/settings/apps etc.) and an extra `gunicorn_cfg.py` with the following content:


    import os
    user_home = os.environ["HOME"]
    bind = "127.0.0.1:8000"
    workers = 3
    max_requests = 500
    debug = False
    daemon = True
    pidfile = os.path.join(user_home, "pid/gunicorn.pid")


as already mentioned parallel to the projhome folder i have scripts folder, with the following content:

    source /home/django/projhq/bin/activate
    kill `cat /home/username/pid/gunicorn.pid`
    gunicorn_django -c /home/username/projhome/djangopolls/gunicorn_cfg.py


and in the `/etc/nginx/sites-enabled` i made a file mynginx.conf with following content:


    server {
        listen 80;
        root /home/django/projhq/djpolls;
    
        access_log /var/log/nginx/djpolls_access.log;
        error_log  /var/log/nginx/djpolls_error.log;
    
    location /static {
            root /home/username/projhome/djangopolls/static_media;
        }
        location / {
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   REMOTE_HOST      $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   X-FORWARDED-PROTOCOL $scheme;
            proxy_pass http://127.0.0.1:8000;
        }
    }

Now to start the server i need to go to the scripts folder and run the start script, i do that without any error, but when i check the `IP` i get 502 error. 


Where am i wrong???