MySQL max\_allowed\_packet: packet too large - Rocketeers

 On this page

 Knowledge
---------

MySQL max\_allowed\_packet: packet too large
============================================

### [\#Databases](http://rocketee.rs/index.php/databases)

This error means a single query or row exceeded the maximum packet size MySQL accepts. It shows up most often when importing a large dump or storing big blobs.

 Published by Mark van Eijk on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Raise the limit for the running server](#content-raise-the-limit-for-the-running-server)
5. [Set it for an import](#content-set-it-for-an-import)
6. [Check the current value](#content-check-the-current-value)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

You'll hit one of these:

 ```
ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes
ERROR 2006 (HY000): MySQL server has gone away

```

When a client or the server receives a single packet larger than `max_allowed_packet`, it rejects it and drops the connection, which often surfaces as the misleading "server has gone away" message.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- Importing a database dump that contains very large multi-row `INSERT` statements.
- Storing large `BLOB` / `TEXT` values, like images or big JSON columns.
- A bulk insert that builds one enormous query.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-raise-the-limit-for-the-running-server "Permalink")Raise the limit for the running server

You can set it at runtime without a restart (the value is in bytes, this is 256 MB):

 ```
SET GLOBAL max_allowed_packet = 268435456;

```

A runtime change is reset on restart, so make it permanent in `my.cnf` (`/etc/mysql/my.cnf` or a file under `/etc/mysql/conf.d/`):

 ```
[mysqld]
max_allowed_packet = 256M

```

Then restart MySQL:

 ```
systemctl restart mysql

```

### [\#](#content-set-it-for-an-import "Permalink")Set it for an import

When the error happens during an import, the **client** also has its own limit. Pass it on the command line so both sides agree:

 ```
mysql --max_allowed_packet=256M -u forge -p my_app
