504 Error in Azure Web App (Fastapi & Postgres) with structure like Microsoft Fastapi/Postgres Demo App

Nicolas Joye 0 Reputation points
2025-05-29T16:23:48.27+00:00

I keep getting 504 errors when trying to connect to the Postgres database from an app that I built using the microsoft fastapi/postgres demo app. I followed these instructors to the T. https://learn.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app-fastapi?tabs=windows&pivots=azure-portal and even cloned the repo here https://github.com/Azure-Samples/msdocs-fastapi-postgresql-sample-app. I have seemingly tried everything. This happens not just on a cold start, but even after the cold start. I am using the $250 premium tier for the web app. I am using the General Purpose 2-64 vCores Azure Database for PostgresSQL flexible Server with Standard_D2s_v3 (2 vCores, 8 GiB memory, 3200 max iops) with 128 GiB storage and P10 (500 iops) performance tar. With this type of setup, i would assume a speedy response from any call that is within a limited character length. This is currently happening with small or large calls, seemingly agnostic to the size of call. Since I used the sample project, I assumed the setup that connects to the database would be solid. Thank you for your support.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,905 questions
{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.