# Cloud SQL connections dropped during maintenance or failover (server closed the connection)

**Code:** `maintenance` · **Category:** Google Cloud / Firebase · **Seen on:** Google Cloud, PostgreSQL, MySQL

Connections reset when Cloud SQL restarts for maintenance, a flag change or a high-availability failover.

## 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

1. Add retry/backoff and pool validation
2. Set a maintenance window
3. Use HA and the Auth Proxy/connector with reconnect

## Detailed fix by platform

### Python

1. `engine = create_engine(URL, pool_pre_ping=True, pool_recycle=1800)`

## How to diagnose

1. **Window** — Known?
2. **Retry** — Implemented?
3. **Pool** — Validated?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/gcp/cloudsql-maintenance-connection-reset)
