Diagnosing Azure SQL Database Transient Connection Failures (Errors 40197, 40613, 40501)
Azure SQL errors 40197, 40613, and 40501 look identical to your app but have three different causes. Map each error to reconfiguration, unavailability, or throttling, then apply the matching fix.
28 Aug 2026, 00:51 UTC

The condition: connections drop in bursts, then everything looks fine
Your application intermittently throws SqlException with error 40197 ("The service has encountered an error processing your request"), 40613 ("Database is not currently available"), or 40501 ("The service is currently busy"). The failures cluster in short bursts — often around deployments, failovers, or load spikes — and then disappear without anyone changing anything. Retrying the same query seconds later usually works.
The useful takeaway: these three errors are almost never application bugs. They map to three distinct platform behaviors — reconfiguration, database unavailability, and resource throttling — and each has a different fix. Treating them all as "just retry" hides throttling problems, and treating them all as outages wastes escalation effort on normal platform behavior.
This guide assumes Azure SQL Database (single database or elastic pool). Error numbers and diagnostic views differ for SQL Managed Instance and SQL Server on VMs, so confirm your deployment model first.
Mapping the error to the cause
| Error | Typical meaning | First place to look |
|---|---|---|
| 40197 / 40613 | Planned or unplanned reconfiguration: failover, patching, or compute migration | sys.event_log in the master database |
| 40501 | Resource governance throttling: DTU/vCore, worker, or session limits hit | Portal metrics: CPU/DTU percentage, worker percentage |
| 10053 / 10054 (network reset) | Idle connection dropped by an intermediate device (NAT, load balancer) | Connection lifetime vs. idle timeout of network path |
The distinction matters because the fixes diverge: reconfigurations call for retry logic, throttling calls for load reduction or scaling, and idle drops call for connection lifetime tuning.
Check 1: correlate failures with platform events
Run this against the master database of the logical server, using a login with permission to query these views:
SELECT start_time, end_time, event_type, event_subtype_desc, severity
FROM sys.event_log
WHERE database_name = 'your-database-name'
AND start_time >= DATEADD(hour, -24, SYSUTCDATETIME())
ORDER BY start_time DESC;Compare start_time/end_time for availability events against the timestamps in your application error logs. If your 40197/40613 bursts line up with recorded reconfiguration events, the platform behaved as designed and your fix is client-side resilience, not a support case.
Limitation: sys.event_log keeps only a rolling window of recent events. Run this within hours of an incident, or the evidence is gone. For longer retention, route diagnostic logs to a Log Analytics workspace ahead of time.
Check 2: separate throttling from maintenance
In the Azure portal, open the database and review metrics for the incident window: CPU percentage (or DTU percentage on DTU-based tiers), worker percentage, and deadlocks. Also check Resource Health for the database, which records platform-side events.
Interpretation:
- Worker or CPU percentage pinned near 100% during 40501 bursts → throttling. Proceed to the throttling fix.
- Metrics normal but Resource Health shows an event → platform reconfiguration. Proceed to the retry fix.
- Neither shows anything, and failures are single-connection resets → suspect idle-connection drops.
Portal blade names and metric labels shift over time, so treat the navigation above as approximate; the metric concepts are stable.
Fix for reconfigurations: bounded retry with backoff
Azure SQL Database reconfigurations are normal and typically last seconds. The supported mitigation is transient-fault retry logic. With recent Microsoft.Data.SqlClient versions, you can enable the built-in retry provider in the connection string:
Server=tcp:yourserver.database.windows.net,1433;Database=yourdb;
Authentication=Active Directory Default;
Connect Retry Count=5;Connect Retry Interval=10;For finer control (per-command retries, jitter, logging), use a library such as Polly around your data-access calls. Two rules:
- Use exponential backoff with jitter. Aggressive fixed-interval retries amplify 40501 throttling by adding load exactly when the engine is shedding it.
- Only retry idempotent operations, or make operations idempotent (e.g., upsert by natural key). Retrying a non-idempotent insert can duplicate rows.
Verification: trigger a controlled reconfiguration (a manual failover where your configuration supports it, or a planned scale operation in a test environment) and confirm the application recovers within the retry window without surfacing errors to users.
Fix for throttling: reduce work or raise the ceiling
If 40501 correlates with high worker/CPU percentage:
- Find the top resource-consuming queries with Query Store or
sys.dm_exec_requestsduring a spike, and tune the worst offenders (missing indexes, large scans, chatty per-row calls replaced with batches). - Cap application concurrency — connection pool max size and parallel worker counts — so you stop queuing work the engine will only throttle.
- If the workload is legitimately sized for a higher tier, scale up. Then confirm worker percentage drops below the throttling threshold during the next peak.
Verification: rerun a load test that previously triggered 40501 and confirm both the error count and peak worker percentage fall.
Fix for idle-connection resets
If failures are sporadic network resets on connections that sat idle, an intermediate device is likely dropping idle TCP sessions. Keep the ADO.NET connection pool enabled (it is by default) and set a maximum connection lifetime below the idle timeout of your network path:
...;Max Pool Size=100;Connection Lifetime=300;This forces pooled connections to be recycled every 300 seconds, so the pool stops handing out connections a NAT device has already forgotten. On Linux clients, also review TCP keep-alive settings if resets persist.
When to escalate to Microsoft support
Open a support case when any of these hold:
sys.event_logshows repeated unplanned failovers for the same database within days.- Resource Health reports an ongoing platform issue affecting your database.
- Retry logic and a tier increase have not reduced failure rates after a defined observation window (for example, one full business cycle).
Include the server name, database name, UTC timestamps of failures, error numbers, and the sys.event_log output — support will ask for exactly these.
Make the next incident easier
Enable diagnostic settings on the database to send errors and timeouts to a Log Analytics workspace, and alert on transient-error counts above a baseline. That converts the next burst from a forensic scramble into a chart you already have.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.