# MySQL ERROR 2006 (HY000): MySQL server has gone away

**Code:** `2006` · **Category:** MySQL · **Seen on:** MySQL

The connection to MySQL was closed — usually by a timeout or a packet larger than `max_allowed_packet`.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/mysql/2006-mysql-server-has-gone-away)
