Question
Getting 502 Bad Gateway after restarting gunicorn
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"
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.
×