2013 🐬 MySQL

MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query

The connection dropped mid-query — server crash/restart, timeouts, or a proxy cutting long queries.

Seen on: MySQL

Meaning

Long-running queries exceeding net_read_timeout/proxy timeouts, oversized packets, or the server being OOM-killed.

Common causes

  • Server crashed/restarted (OOM)
  • Long query hitting net_read_timeout or proxy idle timeout
  • Packet larger than max_allowed_packet

⚡ Quick fix

  1. Check the MySQL error log for crashes
  2. Raise net_read_timeout / wait_timeout for long jobs
  3. Optimize the long query

Detailed fix by platform

MySQL

  1. SET GLOBAL net_read_timeout = 600;

How to diagnose

  1. Server — Restarted?
  2. Query — Duration?

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