Error fix · Developer errors

MySQL ERROR 1153: Got a Packet Bigger Than max_allowed_packet

Fix MySQL ERROR 1153 Got a packet bigger than max_allowed_packet. Raise it on both server and client, handle mysqldump imports, and avoid oversized rows.

Error messageERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes

By SiteDownCheck Editorial · Updated November 18, 2026 · 4 min read

MySQL and MariaDB communicate in packets. A single statement, row, or blob sent in one go cannot exceed max_allowed_packet. When a client or a dump file sends something larger, the server rejects it with error 1153 and usually closes the connection.

ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes

You see it when importing a big .sql file, inserting a large blob or base64 string, saving a huge serialized option in a CMS, or running a bulk INSERT with thousands of rows.

Check the current value

SHOW VARIABLES LIKE 'max_allowed_packet';

The value is in bytes. MySQL 8.0 defaults to 64 MB (67108864); MySQL 5.7 defaults to 4 MB (4194304), and MariaDB's default has changed across versions (16 MB in recent ones), so read yours instead of assuming. The upper limit is 1 GB (1073741824).

Raise it on the server

For the running server, which takes effect for new connections only:

SET GLOBAL max_allowed_packet = 268435456;   -- 256 MB

Reconnect before testing, since existing sessions keep the old value. To make it survive a restart, add it to the config file:

[mysqld]
max_allowed_packet = 256M

Typical files are /etc/mysql/my.cnf, /etc/mysql/mysql.conf.d/mysqld.cnf or /etc/my.cnf. Restart afterward (sudo systemctl restart mysql) and verify with SHOW VARIABLES. On managed services such as RDS or Cloud SQL, change it in the parameter group or flags console instead of editing a file.

Raise it on the client too

The limit applies to both directions. The mysql client, mysqldump and connector libraries each have their own max_allowed_packet, and the effective size for a message is the smaller of the two sides.

mysql --max_allowed_packet=256M -u root -p shop < shop.sql
mysqldump --max-allowed-packet=256M -u root -p shop > shop.sql

Or in my.cnf:

[client]
max_allowed_packet = 256M

[mysqldump]
max_allowed_packet = 256M

Application libraries expose it differently: for example, the JDBC property maxAllowedPacket, or PHP's pdo_mysql, which follows the server value. Check your driver's documentation.

Import files that still fail

A dump made with extended inserts packs many rows into one statement. The size is controlled by the dump's net_buffer_length (mysqldump --net-buffer-length). If you must import a dump you cannot regenerate on a server where you cannot change limits, re-dump with smaller statements:

mysqldump --skip-extended-insert -u root -p shop > shop-small.sql

That produces one INSERT per row. It is slower to import but each statement is small. For single rows with big blobs, the packet limit must still fit the biggest row.

Importing through phpMyAdmin or a hosting panel adds web limits (upload_max_filesize, post_max_size, execution time) before MySQL is involved; use the command line for large files.

Does the table definition matter?

Yes, in a different way. Column types cap values: BLOB holds 64 KB, MEDIUMBLOB 16 MB and LONGBLOB 4 GB. If you store a 20 MB file in a BLOB, you will see data-too-long errors or truncation, regardless of packet size. Pick a column type that fits.

Storing large files in the database is rarely wise. Keep files on disk or in object storage and store only the path in MySQL.

An oversized packet sometimes shows up as a dropped connection rather than a clear error 1153, especially on older clients. If you see MySQL server has gone away or Lost connection during query while writing large data, raise max_allowed_packet first. Also remember that replication copies the statement to replicas, so a replica with a smaller max_allowed_packet than the source can stop replicating with a packet error. Match the setting on both.

Choose a sensible size

Do not set it to 1 GB "just in case". The server may allocate memory for large packets per connection when they are used. Choose a value slightly above your largest legitimate statement, such as 64 MB or 256 MB, and fix the application if it ships huge payloads, for example base64-encoded images. You can inspect that kind of payload with the Base64 Encoder/Decoder, and spot bloated JSON with the JSON Validator.

Next steps

FAQ

What is the maximum value for max_allowed_packet?

1 GB (1073741824 bytes). Values above that are capped.

Do I need to restart MySQL after changing it?

Not if you use SET GLOBAL, but the change applies only to new connections and is lost on restart unless you also write it to the config file.

Why does the error persist after I raised the server value?

The client may have its own, smaller limit. Pass --max_allowed_packet to mysql or mysqldump, or set it in the [client] section.

Can this cause data loss?

The rejected statement is not executed, so nothing is partially written, but the import or request fails. Rerun it after raising the limit.

Get notified when this fix updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.