An Azure managed PostgreSQL database service for app development and deployment.
Hello Beriflapp DEV,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having connection issue to postgres sql flexible server.
To resolve Azure PostgreSQL Flexible Server connection failures showing “FATAL: pg_hba.conf rejects connection…”, begin by verifying whether your server uses Public Access, Private Endpoint, or VNet Integration, since access control depends on these modes rather than manual pg_hba configuration. Immediately test TLS with:
psql "host=<server>.postgres.database.azure.com port=5432 dbname=<db> user=<user> sslmode=require"
Correct TLS usage and client egress IP alignment are foundational steps. - https://learn.microsoft.com/en-us/azure/postgresql/troubleshoot/how-to-troubleshoot-common-connection-issues, and https://stackoverflow.com/questions/62301317/azure-database-for-postgresql-server-no-pg-hba-conf-entry-for-host
If public access is enabled, determine your current outbound IP and ensure it is permitted in Networking > Firewall Rules, because maintenance can shift outbound paths. Always enforce encrypted connections by keeping sslmode=require and avoiding disabling require_secure_transport. Reference tests and TLS rules here: Azure TLS guidance and CLI error behavior.
For private endpoint and VNet-integrated deployments, confirm that you are connecting from inside the permitted subnet, and validate that DNS resolves your server name to a private IP using: nslookup <server>.postgres.database.azure.com
If resolution shows a public IP from inside the VNet, re-link your Private DNS Zone. Guidance: VNet Integration Networking and Private Endpoint DNS checks.
If authentication was switched to Microsoft Entra-only, all Postgres-password users will fail with the same pg_hba-style message. Verify authentication settings and re-enable Postgres authentication or migrate clients to token-based login. See the confirmed behavior here: Auth mode causing pg_hba rejection.
Finally, if errors aligned with the scheduled maintenance (Tracking ID RMB6‑HFZ), implement retry logic because short‑lived disconnects are normal, but persistent failures beyond 60 seconds require investigation. Confirm event timing in Azure Service Health: Maintenance behavior and Planned Maintenance Panel.
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.