502 error django deployment

Cornelis Buitelaar 0 Reputation points
2025-02-15T18:54:36.5066667+00:00

I'm deploying a Django app on Azure Web App using Gunicorn and keep getting a 502 Bad Gateway error. Despite binding to the correct port, setting up environment variables for Key Vault, and enabling SCM_DO_BUILD_DURING_DEPLOYMENT for Oryx builds, the site never fully starts. I need to figure out why Gunicorn won't serve the app properly, even though the deployment logs seem fine.

I set SCM_DO_BUILD_DURING_DEPLOYMENT=true, placed my requirements.txt in the project root so Oryx could install dependencies, and updated my startup command to gunicorn --bind=0.0.0.0:$PORT. I also configured environment variables for Key Vault, and tested collecting static files locally vs. on Azure. I expected the Azure Web App to run Gunicorn without errors. Instead, I keep getting a 502 Bad Gateway, and my logs show no direct failure message—just that the service never properly responds.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,320 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.