Cloud SQL connections dropped during maintenance or failover (server closed the connection)
Connections reset when Cloud SQL restarts for maintenance, a flag change or a high-availability failover.
Cloud SQL maintenance connection resetserver closed the connection unexpectedly Cloud SQL failoverLost connection to MySQL server during query Cloud SQL maintenanceCloud SQL failover connections droppedterminating connection due to administrator command Cloud SQL Meaning
Expect brief downtime. Set a maintenance window, use HA, make clients retry with exponential backoff, validate pooled connections (pool_pre_ping, testOnBorrow) and keep short transactions. Re-resolve the instance after failover.
Common causes
- Maintenance restart
- HA failover
- Flag change requiring restart
- Stale pooled connections
- No retry logic in the app
⚡ Quick fix
- Add retry/backoff and pool validation
- Set a maintenance window
- Use HA and the Auth Proxy/connector with reconnect
Detailed fix by platform
Python
engine = create_engine(URL, pool_pre_ping=True, pool_recycle=1800)
How to diagnose
- Window — Known?
- Retry — Implemented?
- Pool — Validated?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Auth Proxy Cloud SQL Auth Proxy: failed to connect — IAM permission, API or IAM DB authentication problem
- Cloud SQL: failed to connect to instance Cloud SQL: failed to connect to `host=PROJECT:REGION:INSTANCE user=app database=db`: dial error (timeout) / Cloud SQL Auth Proxy: failed to connect to instance
- Cloud SQL: too many connections Cloud SQL: FATAL: remaining connection slots are reserved / MySQL: ERROR 1040 (08004): Too many connections
Most viewed in Google Cloud / Firebase
- Missing or insufficient permissions Firestore: FirebaseError: [code=permission-denied]: Missing or insufficient permissions
- Container failed to start Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
- 409: The resource already exists Compute Engine: ERROR: (gcloud.compute.instances.create) Could not fetch resource: The resource 'projects/p/zones/z/instances/vm-1' already exists
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026