MySQL & MariaDB error 1153: Got a packet bigger than 'max_allowed_packet' bytes
Got a packet bigger than 'max_allowed_packet' bytes (8.0.46) A single statement, row or value sent to (or from) the server exceeds max_allowed_packet. MySQL 8.0+ clients report it as 1153; MySQL 5.x and MariaDB clients usually just see "server has gone away" (2006).
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_NET_PACKET_TOO_LARGE | ER_NET_PACKET_TOO_LARGE |
| SQLSTATE | 08S01 | 08S01 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
Every statement and every row in a result travels as one packet, which can’t exceed max_allowed_packet (default 4 MB on MySQL 5.6/5.7, 64 MB on MySQL 8.0+, 16 MB on MariaDB). When a client sends more, the server closes the connection. In our tests, MySQL 8.0, 8.4 and 9.x clients show 1153, while MySQL 5.6/5.7 and MariaDB clients show only 2006, which is why so many “server has gone away” searches are really this problem.
Why it happens
- Large BLOB / LONGTEXT values: images, PDFs, JSON documents.
- Very long multi-row INSERTs, as produced by
mysqldumpfrom a server with a bigger limit. GROUP_CONCATorREPEATresults above the limit (those return NULL with warning 1301 instead).
How to fix it
- Raise it on the server:
SET GLOBAL max_allowed_packet = 67108864;and inmy.cnf([mysqld] max_allowed_packet=64M). New connections pick it up. - Raise it on the client too:
mysql --max-allowed-packet=64M,mysqldump --max-allowed-packet=…, or the driver option. - For dumps from another server, match its value, or dump with
--net-buffer-lengthso INSERTs are split. - Store very large files outside the database and keep a path or URL in the row.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database and the test data:CREATE DATABASE demo; USE demo; CREATE TABLE big (b LONGBLOB);As an admin, lower the limit to 1 MB (new connections pick it up).
SET GLOBAL max_allowed_packet = 1048576;Reconnect and send a statement of about 3 MB, for example from a shell:
{ printf "INSERT INTO big VALUES ('"; head -c 3000000 /dev/zero | tr '\0' a; printf "');\n"; } | mysql -u root -p demoPut the limit back afterwards (64 MB is the MySQL 8.0 default).
SET GLOBAL max_allowed_packet = 67108864;
You get: ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes(9.7.4)
Verified fixes
Raise max_allowed_packet on the server (and the client)
Raise the server limit (and put it in my.cnf under [mysqld] so it survives a restart).
SET GLOBAL max_allowed_packet = 67108864; -- 64 MBReconnect with a matching client limit and send the statement again.
mysql -u root -p --max-allowed-packet=64M demo < big-insert.sql
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| Insert a 3 MB value while max_allowed_packet is 1 MB repro | ✓ 2006 | ✓ 2006 | ✓ 1153 | ✓ 1153 | ✓ 1153 | ✓ 2006 | ✓ 2006 | ✓ 2006 | ✓ 2006 |
| Raise max_allowed_packet on the server (and the client) fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |