An Azure managed PostgreSQL database service for app development and deployment.
The error “A task is cancelled” when connecting to Azure Database for PostgreSQL flexible server usually indicates a connection problem (timeout, firewall, or transient connectivity) rather than a PostgreSQL engine error.
Troubleshoot in this order:
- Check for transient connectivity issues
- Go to the Microsoft Azure Service Dashboard and verify there is no ongoing outage for Azure Database for PostgreSQL in the region where the flexible server is deployed.
- Ensure the client or application includes retry logic for transient errors, as connections can drop briefly during maintenance or when scaling vCores or changing service tier.
- Verify basic connectivity and firewall
- Confirm that the client IP or the subnet where the application runs is allowed in the flexible server’s firewall or network rules.
- Test connectivity using
psqlor another PostgreSQL client directly to the flexible server hostname and port 5432 from the same environment where the application runs. If this fails or times out, the “task cancelled” in the app is likely a symptom of this connectivity failure.
- Check for resource or quota limits
- If the server is under heavy load or near resource limits, connections can appear to hang or be dropped. Review vCore, storage, and connection usage against the documented limits for Azure Database for PostgreSQL flexible server.
- If the workload after migration from the VM exceeds default quotas (for example, vCores or other flexible server limits), request a quota increase:
- In Azure portal, go to Help + support → Create a support request.
- Set Issue type to Service and subscription limits (quotas).
- Set Quota type to Azure Database for PostgreSQL flexible server.
- Provide details of workload and required vCores or other resources.
- If connection issues persist
- Treat the “task cancelled” as a persistent connectivity error if it recurs regularly.
- If the duration of errors exceeds about 60 seconds or occurs multiple times per day, create an Azure support request from the Azure portal (even with a Developer support plan) using Help + support → Create a support request, selecting the Azure Database for PostgreSQL flexible server service and describing the connection symptoms and timestamps.
These steps address the most common causes of application-level “task cancelled” errors after moving to Azure Database for PostgreSQL flexible server: transient platform events, firewall/network misconfiguration, and resource or quota constraints.
References: