I followed meticulously the official AWS guide to deploy a Django App to Elastic Beanstalk ( https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html ) for a school project. It is working locally, but when I try to deploy it shows a 500 Error message. I went through many adjustments in my code but they don't seem effective. The AWS dashboard shows one warning that says: Environment health has transitioned from OK to Warning. 100% of the requests are failing with HTTP 5xx. Could it be a timezone problem as I am currently in Europe?
I tried to change debug mode from true to false, but I don't think that's the problem. the I truly do not understand why it's not working, I never got an error in the execution in the terminal and it always deployed everything correctly. It is just not showing the web page for some reason.
MacBook-Air-di-Davide:ebdjango davidemerlin$ eb create django-env
Creating application version archive "app-190718_165248".
Uploading ebdjango/app-190718_165248.zip to S3. This may take a while.
Upload Complete.
Environment details for: django-env
Application name: ebdjango
Region: eu-central-1
Deployed Version: app-190718_165248
Environment ID: e-3mxbcch2rm
Platform: arn:aws:elasticbeanstalk:eu-central-1::platform/Python 3.6 running on 64bit Amazon Linux/2.8.6
Tier: WebServer-Standard-1.0
CNAME: UNKNOWN
Updated: 2019-07-18 14:52:51.893000+00:00
Printing Status:
2019-07-18 14:52:51 INFO createEnvironment is starting.
2019-07-18 14:52:52 INFO Using elasticbeanstalk-eu-central-1-725098113628 as Amazon S3 storage bucket for environment data.
2019-07-18 14:53:16 INFO Created security group named: sg-0d5da9ecf4206ab11
2019-07-18 14:53:32 INFO Created load balancer named: awseb-e-3-AWSEBLoa-GCK3W368WNAW
2019-07-18 14:53:32 INFO Created security group named: awseb-e-3mxbcch2rm-stack-AWSEBSecurityGroup-10HEII5KA2YFV
2019-07-18 14:53:32 INFO Created Auto Scaling launch configuration named: awseb-e-3mxbcch2rm-stack-AWSEBAutoScalingLaunchConfiguration-16YCNNVJS4QJG
-- Events -- (safe to Ctrl+C)
eb status
Environment details for: django-env
Application name: ebdjango
Region: eu-central-1
Deployed Version: None
Environment ID: e-3mxbcch2rm
Platform: arn:aws:elasticbeanstalk:eu-central-1::platform/Python 3.6 running on 64bit Amazon Linux/2.8.6
Tier: WebServer-Standard-1.0
CNAME: django-env.q7fdcfwnii.eu-central-1.elasticbeanstalk.com
Updated: 2019-07-18 14:53:32.535000+00:00
Status: Launching
Health: Grey
Alert: An update to the EB CLI is available. Run "pip install --upgrade awsebcli" to get the latest version.
(base) MacBook-Air-di-Davide:ebdjango davidemerlin$ eb deploy
Creating application version archive "app-190718_165726".
Uploading ebdjango/app-190718_165726.zip to S3. This may take a while.
Upload Complete.
2019-07-18 14:57:28 INFO Environment update is starting.
2019-07-18 14:57:31 INFO Deploying new version to instance(s).
2019-07-18 14:57:53 INFO New application version was deployed to running EC2 instances.
2019-07-18 14:57:53 INFO Environment update completed successfully.
Alert: An update to the EB CLI is available. Run "pip install --upgrade awsebcli" to get the latest version.
(base) MacBook-Air-di-Davide:ebdjango davidemerlin$ eb open'''
I expect to load the page at django-env.q7fdcfwnii.eu-central-1.elasticbeanstalk.com
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.
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.
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:
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
Changed WSGI Path to :
WSGIPath: YourDjangoProjectFolder.wsgi:application
All other things are same as described in that documentation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.