[Solved]-502 Bad Gateway from relocated instance on AWS EC2


Effectively … Environment variables were the culprits (and me, for not realizing), they were not configured properly therefore Django crashes when Gunicorn tries to run it.

And I solved this problem by checking all environment vars and setup properly according to my instance EC2 … thnks so much to @Serj Zaharchenko for the simple but powerful clue.



I found this, don’t know if solves your problem.

The first line of the gunicorn_django file was “#!/opt/django/env/mysite/bin/python”, which is the path of my virtualenviroment python path. The problem solved by replace it as “#!/usr/bin/env python”

Leave a comment