2006 🐬 MySQL

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.

Seen on: MySQL

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

  1. Raise max_allowed_packet (e.g. 64M) for big imports
  2. Reconnect on failure in long-running workers
  3. Check server logs for crashes

Detailed fix by platform

MySQL

  1. my.cnf: [mysqld] max_allowed_packet=64M; restart.

How to diagnose

  1. Size — Large query/packet?
  2. Idle — Connection idle long?
  3. Server — Restart/crash in logs?

🧠 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.