An Azure managed PostgreSQL database service for app development and deployment.
Hello Md Azimul Islam Sheblu,
Greetings! Thanks for raising this question in Q&A forum.
The classic reason this happens, when local connects fine but your Container App times out, is that the network path from your laptop to Postgres is allowed, but the network path from the Container App to Postgres is not. Your app is not getting an error back, it is just timing out at 35 seconds, which means the connection attempt is hanging rather than being actively rejected. That hanging behavior is the typical sign of a firewall or network rule silently dropping the packets rather than a credentials or pool exhaustion problem.
Here is a simple way to narrow it down and fix it.
Confirm whether it is networking or something deeper From inside one of your Container App containers (use the Container Apps console/exec feature in the portal), run a basic TCP check to the database host and port, for example nc -zv yourserver.postgres.database.azure.com 5432 (or 6432 if you are pointing at PgBouncer). If this hangs and times out, the problem is purely network level, not PgBouncer, not pooling, not your query. If it connects instantly but psql with credentials still fails, then it is an auth or PgBouncer pool issue instead.
Check how your Postgres server is exposed If your PostgreSQL flexible server uses public access with firewall rules, the rule that lets your local machine in is almost certainly your home or office IP. Azure Container Apps egress traffic from a different, often dynamic, outbound IP, so unless that specific IP (or "Allow public access from any Azure service within Azure" type rule) is added to the Postgres firewall, the Container App's connection attempts get silently dropped while your laptop sails through.
Add the right access for the Container App If you want a quick fix, get your Container App's outbound IP and add it as an explicit firewall rule on the Postgres server. If your Container Apps environment does not have a stable outbound IP (common on the Consumption plan without VNet integration), this quick fix will not be reliable long term.
Move to private networking for the real fix The properly supported, more stable setup for two Container Apps talking to one Postgres server in production is VNet integration for your Container Apps environment plus a private endpoint or private access for the Postgres server, so traffic never goes over the public internet or through IP based firewall rules at all. This removes the whole class of intermittent timeout issues caused by changing outbound IPs.
Once networking is confirmed working, then look at PgBouncer After the basic TCP test succeeds reliably from inside the container, if you still see slow connections under load, that is when it is worth checking pgbouncer.max_client_conn and pgbouncer.default_pool_size in the server parameters, and running SHOW POOLS on the PgBouncer admin port to see if connections are queuing.
You can find the setup guidance here: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-firewall-rules https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-networking-private
If this answer helps you kindly accept the answer which will help others who have similar questions
Best Regards,
Jerald Felix.