DBAtlas · Database operations atlas

2013: Lost connection to MySQL server during query

MySQL

What does it mean?

The connection between the client and the MySQL server dropped while the query was running. It was cut before the server could respond or return results.

Why does it happen?

A long-running query exceeding net_read_timeout/net_write_timeout; the server terminating the query/connection due to out-of-memory (OOM); a network outage; exceeding max_allowed_packet; the server crashing or restarting; a very large result set.

How to fix it

Check network stability and the server error log; see whether there was an OOM or crash. Increase the timeouts: SET GLOBAL net_read_timeout = 120; Split large queries into batches. Increase max_allowed_packet. Add connection retry logic in the application. Optimize long queries.

Open in DBAtlas →

More from this engine