Django and Nginx: 502 error

Posted April 19, 2014 15.4k views
Hello :) While trying to deploy my app to Digital ocean I did everything according to this tutorial: While Gunicorn is working perfectly and opens my app, Nginx, however, does not work, or causes a 502 error. Nginx log says, that : 2014/04/19 02:43:52 [error] 896#0: *62 connect() failed (111: Connection refused) while connecting to upstream, client:, server:, request: "GET / HTTP/1.1", upstream: "", host: "" My nginx configuration file looks like this: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name; access_log off; location /static/ { alias /opt/myenv/static/; } location / { proxy_pass; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } In Django.settings I have ALLOWED_HOSTS setting set to '[*]'

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer
I changed the proxy_pass; line under location / to my servers IP address (instead of loccalhost) and everything worked. I am not sure if it's good decission or not.