Knowledge
MySQL max_allowed_packet: packet too large
#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
- About the error
- Why do I see this error
- Solution
- Raise the limit for the running server
- Set it for an import
- Check the current value
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.
Why do I see this error
- Importing a database dump that contains very large multi-row
INSERTstatements. - Storing large
BLOB/TEXTvalues, like images or big JSON columns. - A bulk insert that builds one enormous query.
Solution
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
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 < dump.sql
See importing a database from the command line for the full import workflow.
Check the current value
To see where it's set right now:
SHOW VARIABLES LIKE 'max_allowed_packet';
If you regularly export and re-import large databases, it's worth setting a generous value on both the source and destination so dumps move cleanly. See exporting a database from the command line.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
Related articles
Stream MySQL backup directly to S3 bucket
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.
Export MySQL database using command line
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.