AWS Django deployment Health checks failed with these codes: [502]

174 views Asked by At

I'm trying to deploy a Django app on AWS Elastic beanstalk. I'm not an experienced tech guy but learning about AWS.

In the .ebextensions directory,I added a configuration file named django.config::

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: app.wsgi:application

I followed the following deployment steps:

eb init -p python-3.7 app-tutorial

eb init

eb create django-env

eb status

Under eb status, the health status is red.

Under EC2 > Target groups on AWS dashboard, Health status details are :

Health checks failed with these codes: [502]

How to troubleshoot this error so as to make the app run on the address provided by the CNAME of 'eb status' command?

Some of the error logs are:

2023/05/26 12:31:08 [error] 2705#2705: *51 connect() failed (111: Connection refused) while connecting to upstream, client: ....., server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "....."

I am running Django version 4 on python 3.11 on my PC whereas the supported version on aws is 3.7. Can this cause any trouble if I deploy the Django app on aws python 3.7?

I also tried solutions from here: 502 bad gateway Elastic Beanstalk Spring Boot

I do not how to add server port like the one added in Java application.

Nginx access logs from eb logs --all:

172.31.44.172 - - [27/May/2023:17:03:46 +0000] "GET / HTTP/1.1" 502 150 "-" "ELB-HealthChecker/2.0" "-"

Tried many solutions from various stackoverflow posts but nothing seems to work. Please help!

0

There are 0 answers