The Python Oracle

Internal Server Error 500 when deploying Django Application to Elastic Beanstalk

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Ominous Technology Looping

--

Chapters
00:00 Internal Server Error 500 When Deploying Django Application To Elastic Beanstalk
01:52 Answer 1 Score 1
02:18 Answer 2 Score 2
02:40 Accepted Answer Score 1
03:19 Thank you

--

Full question
https://stackoverflow.com/questions/5709...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #bash #amazonwebservices #amazonelasticbeanstalk

#avk47



ANSWER 1

Score 2


Did you resolve it? I struggled for weeks but with a 502 after following exactly the instructions.

Then I found this post and deduced it was a typo or outdated instructions (*/wsgi.py should be *.wsgi:application).

Created a pull request to AWS docs and they've updated since.




ANSWER 2

Score 1


I was having the same problem, until I realized I hadn't included the following line in my settings.py file:

ALLOWED_HOSTS = ['eb-django-app-dev.elasticbeanstalk.com'] 

Replacing the link inside the brackets with my own custom application link, as stated in step 5 of the tutorial.

After saving the file and committing, I was able to get rid of the 500 error.




ACCEPTED ANSWER

Score 1


I was trying to deploy my Django Rest Api to Beanstalk by following this documentation. And I encountered the same Status Code 500 error.

I managed to solve this problem by making below two changes:

  1. AWS Beanstalk's python 3.6 environment doesn't seem to work well with latest Django versions. So I created a new python 3.7 environment using this command.

    eb init -p python-3.7 django-tutorial
    
    
  2. Changed WSGI Path to:

    WSGIPath: YourDjangoProjectFolder.wsgi:application

All other things are same as described in that documentation.