Courseiva
DeploymenteasyMultiple ChoiceObjective-mapped

Elastic Beanstalk 502 Error After Deployment

A company uses AWS Elastic Beanstalk to deploy a Python web application. After a recent deployment, the environment health turns 'Severe' and the application becomes unresponsive. The developer checks the logs and finds multiple '502 Bad Gateway' errors from the nginx proxy. The application was working before the deployment. What is the MOST likely cause?

Quick Answer

The answer is a bug in the new application code that causes the application to crash. A 502 Bad Gateway error from the nginx proxy indicates that the reverse proxy cannot establish a successful connection to the application backend running on the Elastic Beanstalk environment’s designated port. Since the application was working before the deployment and immediately became unresponsive afterward, the most likely cause is that the new code introduced a runtime error, preventing the application process from starting or causing it to crash repeatedly. On the AWS Certified Developer Associate DVA-C02 exam, this scenario tests your understanding of Elastic Beanstalk’s architecture, specifically how the nginx proxy acts as a front-end and relies on a healthy application listener. A common trap is to suspect configuration issues with the load balancer or security groups, but the key clue is that the error appeared right after a deployment. Memory tip: “502 means the app is sick” — the proxy is healthy, but the backend process is failing.

⚠ Common exam trap

Watch out — candidates often confuse a 502 error with a load balancer misconfiguration or environment variable issue, but the key clue is that the problem started immediately after a code deployment, pointing directly to a bug in the new application code.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The new application code has a bug that causes the application to crash.

A 502 Bad Gateway error from nginx means the reverse proxy cannot communicate with the application backend. Since the application was working before the deployment and became unresponsive immediately after, the most likely cause is a bug in the new code that causes the application process to crash or hang. Elastic Beanstalk's nginx proxy expects a healthy response from the application on the designated port; if the application fails to start or crashes repeatedly, nginx returns 502 errors.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The new application code has a bug that causes the application to crash.

    Why this is correct

    Crashing application causes nginx to return 502.

  • The Procfile is missing from the application source.

    Why it's wrong here

    Missing Procfile would cause a different error.

  • The environment's load balancer is not configured correctly.

    Why it's wrong here

    Load balancer configuration is unlikely to change during deployment.

  • The environment variables are not set correctly.

    Why it's wrong here

    Missing env vars would cause application errors, not necessarily 502.

Visual reference

SW1 Root Bridge SW2 SW3 BLK DP DP RP RP STP blocks one link to prevent loops DP = Designated Port RP = Root Port BLK = Blocked

About these practice questions

One of 724 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on DVA-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A company uses AWS Elastic Beanstalk to deploy a Python web application. After a successful deployment, the environment's health turns 'Severe' and the application returns HTTP 502 errors. What is the most likely cause?

medium
  • A.The EC2 instances have insufficient storage for the deployment.
  • B.The application's requirements.txt file is missing a required dependency.
  • C.The load balancer's health check path is incorrectly configured.
  • D.The RDS database connection string is incorrect.

Why B: A missing dependency in requirements.txt causes the Python application to fail during startup, leading to the EC2 instances reporting an unhealthy status to the Elastic Load Balancer. Elastic Beanstalk relies on the application process to respond to health checks; if the app crashes due to an ImportError, the load balancer receives no valid HTTP response and returns 502 Bad Gateway errors. The environment health turns 'Severe' because the platform detects that the application process is not running or is failing repeatedly.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.