| title | MySQL Aborted Connection | |||||
|---|---|---|---|---|---|---|
| slug | mysql-aborted-connection | |||||
| technologies |
|
|||||
| severity | medium | |||||
| tags |
|
|||||
| related |
|
|||||
| last_reviewed | 2026-06-27 |
[Note] [MY-010914] [Server] Aborted connection 84213 to db: 'appdb' user: 'app' host: '10.0.1.42' (Got timeout reading communication packets)
[Warning] Aborted connection 90551 to db: 'appdb' user: 'app' host: '10.0.1.42' (Got an error reading communication packets)
On the client side this surfaces to the application as:
ERROR 2013 (HY000): Lost connection to MySQL server during query
"Aborted connection" messages are written to the MySQL error log when a
client connection ends abnormally — the client did not send COM_QUIT before the
socket closed. The parenthetical reason is the diagnostic key:
"Got timeout reading communication packets" (idle past a timeout),
"Got an error reading communication packets" (network drop / client crash), or
"interrupted while waiting" . The application typically sees the matching
client-side ERROR 2013. A low rate is normal background noise; a rising rate
signals a real connectivity or pooling problem.
- mysql (connection handler / network layer)
medium — individual queries fail and connections are recycled, which the app can usually retry. It becomes high if a load balancer or firewall is silently cutting healthy long-lived connections under load.
- A connection sat idle longer than
wait_timeout/interactive_timeoutand the server closed it; the pool then tried to reuse the dead connection. - A firewall, NAT, or load balancer idle-timeout silently dropped the TCP connection between client and server.
- The client process crashed or was killed mid-query.
- A single packet exceeded
max_allowed_packet(large BLOB/row). - Network instability (packet loss, MTU/MSS issues) between app and database.
The server expects a clean COM_QUIT. If a read on the connection fails or times
out first, it logs the abort with the reason it observed and increments
Aborted_clients (clean-loss) or Aborted_connects (failed during the
handshake/auth). The most common production pattern is the idle-timeout
mismatch: a connection pool keeps connections far longer than the server's
wait_timeout (default 28800s) or, more often, longer than an intermediate load
balancer's much shorter idle timeout. The connection is silently torn down, and
the next query on it fails with ERROR 2013 while the server logs an aborted
connection.
# Are aborts increasing, and which kind (during handshake vs after connect)?
mysql -u root -p -e "SHOW GLOBAL STATUS LIKE 'Aborted_%';"
# The timeouts that govern how long an idle connection survives
mysql -u root -p -e "SHOW VARIABLES LIKE 'wait_timeout'; SHOW VARIABLES LIKE 'interactive_timeout'; SHOW VARIABLES LIKE 'max_allowed_packet';"
# Read the actual abort reasons (timeout vs error vs packet) from the error log
sudo journalctl -u mysql --since "1 hour ago" | grep -i "aborted connection"
# Rule out a network-level idle reaper between app and DB
ss -tno state established '( dport = :3306 or sport = :3306 )'| Aborted_clients | 1842 | <- connections closed without COM_QUIT
| Aborted_connects | 12 | <- failed during handshake/auth
A fast-climbing Aborted_clients with "Got timeout reading communication
packets" in the log points to idle timeouts; "Got an error reading…" points
to network drops or client crashes; spikes correlated with large rows point to
max_allowed_packet.
-
Align timeouts: make the connection pool's max idle/lifetime shorter than both the server's
wait_timeoutand any load-balancer idle timeout, so the client retires connections before they are killed. -
Enable pool connection validation/keepalive (e.g. test-on-borrow, or a periodic ping) so dead connections are detected before a query runs.
-
If large payloads cause aborts, raise
max_allowed_packeton both server and client to fit the largest legitimate row:[mysqld] max_allowed_packet = 64M
-
Investigate the network path for an idle reaper or packet loss between app and database; increase the LB idle timeout or send TCP keepalives.
-
Ensure clients always close cleanly (
COM_QUIT) rather than dropping sockets.
mysql -u root -p -e "SHOW GLOBAL STATUS LIKE 'Aborted_clients';"
# Re-check after the change: the counter's growth rate should fall sharply.- Keep pool idle/lifetime below the smallest timeout in the path (DB or LB).
- Turn on pool keepalive/validation queries.
- Monitor
Aborted_clients/Aborted_connectsrate, not just absolute value. - Size
max_allowed_packetfor the largest row you actually store.
mysql · connections · networking · timeouts · production