MySQL ERROR 2006 (HY000): MySQL server has gone away
The connection to MySQL was closed — usually by a timeout or a packet larger than max_allowed_packet.
MySQL server has gone away2013 Lost connection to MySQL server during query Meaning
The server dropped the connection: idle longer than wait_timeout, query/packet too big, or the server restarted/crashed.
Common causes
- Long-idle persistent connection exceeded
wait_timeout - Large INSERT/BLOB bigger than
max_allowed_packet - Server crashed or was restarted (OOM)
- Long-running worker reusing an old connection
⚡ Quick fix
- Raise
max_allowed_packet(e.g. 64M) for big imports - Reconnect on failure in long-running workers
- Check server logs for crashes
Detailed fix by platform
MySQL
- my.cnf:
[mysqld] max_allowed_packet=64M; restart.
How to diagnose
- Size — Large query/packet?
- Idle — Connection idle long?
- Server — Restart/crash in logs?
🔧 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
Most viewed in MySQL
Other ways to find it
Where this error sits
Origin: Data. 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 14 Oct 2026