By aamazie
I’m using a one-click app to deploy a Django site using Putty and WinSCP. I was fixing syntax errors in translating my code from Python 3 / Django 2.0 to Python 2 / Django 1.8 (mostly in my urls.py files and my settings), as the virtual machine runs only up to Python 2 / Django 1.8. When I did the command systemctl restart gunicorn.service (usually was using service restart gunicorn) the page no longer gave me the syntax error with all of the exception details, it just gave me a 502 Bad Gateway nginx/1.10.3 (Ubuntu) page. Could this be a sign that my urls.py files and everything has worked and that there is another bug to be fixed now? Or have I dug myself a deeper hole somehow… I think it’s the latter Either way, advice on how to fix it would be super appreciated. I came across some pages on Digital Ocean Community that advised to change the 2 ALLOWED_HOSTS variables in my settings.py but that didn’t work. If you have a specific piece of advice that includes that, though, please share it because I may not have tried it.
Here are some of my latest error logs:
2018/07/31 05:47:10 [error] 2216#2216: *402 upstream prematurely closed connection while reading response header from upstream, client: xxxxxx, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/django/gunicorn.socket:/"
2018/07/31 06:12:27 [error] 2216#2216: *404 upstream prematurely closed connection while reading response header from upstream, client: xxxxxx, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "xxxxxx"
2018/07/31 06:17:06 [error] 2216#2216: *406 upstream prematurely closed connection while reading response header from upstream, client: xxxxxx, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "xxxxxx"
2018/07/31 06:17:07 [error] 2216#2216: *406 upstream prematurely closed connection while reading response header from upstream, client: xxxxxx, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/favicon.ico", host: "xxxxxx"
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello friend!
It is difficult to say with any certainty as the error in question can mask many issues. It basically means that the web server couldn’t get what it needed from the backend, and that you need to troubleshoot the backend to find out why. Do the gunicorn logs have anything different in them? Often they will have more detail.
Kind Regards, Jarland
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.