dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/mysql-2006-server-has-gone-away
MySQL
MySQL 8.0 - 8.4Connection & Packets
6 min read
ERROR 2006 (HY000): MySQL server has gone away / ERROR 2013: Lost connection

MySQL Connection Drops: max_allowed_packet, wait_timeout & OS OOM Killer Forensics

Diagnosing drops from oversized packets exceeding max_allowed_packet, wait_timeout socket termination, and Linux OOM killer termination of mysqld.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: MySQL 8.0 / 8.4 LTS / 9.0

Operational Verification & Reliability Metadata

Last Technical Review: 2 Kasım 2026
Tested VersionsMySQL 8.0.36, 8.4.1 LTS
Required PrivilegesOS dmesg access and MySQL SUPERUSER
Risk Assessment
Highmysqld termination by OOM killer triggers crash recovery and aborted active transactions
Expected Outputmax_allowed_packet expanded to 256MB and clean dmesg without OOM terminations
Rollback Procedure:Revert max_allowed_packet and wait_timeout
MySQL Docs: MySQL server has gone away
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

Applications encounter abrupt connection loss during payload transfer:

plaintext
ERROR 2006 (HY000): MySQL server has gone away ERROR 2013 (HY000): Lost connection to MySQL server during query

▸What You See in Production

Uploading large JSON documents or BLOBs fails immediately, or dormant background workers crash upon resuming operations.


▸Root Cause Matrix

ProbabilityRoot CauseDescription
%50`max_allowed_packet` ExceededOutgoing statement size exceeds server's packet buffer limit.
%30`wait_timeout` Inactivity SeveranceIdle connection exceeds server timeout threshold and gets closed.
%20Kernel OOM KillerOperating system kills mysqld under severe RAM exhaustion.

▸EMERGENCY RUNBOOK (0-5 min)

bash
# 1. Check for OS OOM terminations dmesg -T | grep -i oom # 2. Expand packet buffer size dynamically to 256MB mysql -u root -p -e "SET GLOBAL max_allowed_packet = 256 * 1024 * 1024;" # 3. Increase idle socket timeouts mysql -u root -p -e "SET GLOBAL wait_timeout = 600; SET GLOBAL interactive_timeout = 600;"

▸PERMANENT BLUEPRINT

  1. 1my.cnf Settings: Enforce max_allowed_packet = 256M permanently.
  2. 2Connection Pool Validation: Enable active connection test ping on borrow.
  3. 3Memory Safeguards: Budget buffer pool below 70% of total host RAM.

▸Verification

sql
SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'; SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (82)