How to fix ERROR 1153: Got packet bigger than max_allowed_packet in MySQL
MySQL rejected a data packet that exceeds the max_allowed_packet limit. Increase the max_allowed_packet setting in your MySQL configuration or pass it as a command-line option to handle larger queries, BLOB uploads, or database dumps.
Quick fix
Fixes 1153
SHOW VARIABLES LIKE "max_allowed_packet";- Check your current max_allowed_packet value
- Identify the actual packet size you need
- Temporarily fix via MySQL command (no restart)
- Permanently fix via my.cnf configuration (recommended)
SHOW VARIABLES LIKE "max_allowed_packet";ERROR 1153: Got packet bigger than max_allowed_packet
What this error means
MySQL enforces a maximum size limit on individual network packets exchanged between the client and server. This limit, controlled by the max_allowed_packet system variable, prevents network overload and resource exhaustion. When your application sends a query, INSERT statement, or binary data that exceeds this limit, MySQL rejects it with ERROR 1153 and closes the connection. This commonly occurs during large INSERT/UPDATE operations, database imports, BLOB field handling, or mysqldump restoration.
Typical symptoms
- Database import fails midway through large SQL dump files
- Large INSERT or UPDATE queries are rejected
- Application crashes when uploading large files to BLOB or TEXT columns
- mysqldump restore fails with "Got packet bigger than" error
- Bulk API operations fail intermittently with large payloads
- WordPress or WooCommerce fails to save large post metadata
Common causes
- The max_allowed_packet value (default 16-64MB) is smaller than the data packet being sent
- Importing a SQL dump with rows larger than the limit
- Sending a single SQL statement or query exceeding the limit
- BLOB/TEXT field containing data larger than the configured limit
- Network packet fragmentation or large binary data in INSERT statements
- Client-side max_allowed_packet differs from server-side value
How to fix "ERROR 1153: Got packet bigger than max_allowed_packet"
Log into MySQL and run:
SHOW VARIABLES LIKE "max_allowed_packet";Note the current value in bytes (e.g., 16777216 = 16MB, 67108864 = 64MB). This helps you determine how much to increase it.
Check your largest SQL file or BLOB size:
# For SQL dump files
ls -lh your_dump.sql
wc -c your_dump.sql
# Or estimate based on your use case
# Example: 100MB for large WooCommerce dumps, 256MB for media-heavy appsA safe approach is to set max_allowed_packet to 256M or higher for production systems handling substantial data.
For immediate relief without restarting MySQL:
SET GLOBAL max_allowed_packet = 256 * 1024 * 1024; -- 256MB
SET GLOBAL net_buffer_length = 16 * 1024 * 1024; -- 16MBVerify the change:
SHOW VARIABLES LIKE "max_allowed_packet";Note: This resets when MySQL restarts, so use it only for temporary fixes or testing.
Edit your MySQL configuration file (my.cnf or my.ini, typically at /etc/mysql/my.cnf or C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini):
[mysqld]
max_allowed_packet = 256M
net_buffer_length = 16M
[mysql]
max_allowed_packet = 256MNote: Both [mysqld] (server) and [mysql] (client) sections need the setting if you're importing via command-line. Restart MySQL:
# Linux/Mac
sudo systemctl restart mysql
# Or on macOS with Homebrew
brew services restart mysql
# Windows
net stop MySQL80
net start MySQL80If you only need to import a one-time large dump, pass max_allowed_packet to the client:
mysql --max_allowed_packet=256M -u root -p database_name < huge_dump.sqlFor mysqldump restoration:
mysqdump --max_allowed_packet=256M -u root -p database_name > backup.sql
mysql --max_allowed_packet=256M -u root -p database_name < backup.sqlThis avoids permanent configuration changes for one-off operations.
Re-run your import or query:
mysql --max_allowed_packet=256M -u root -p database_name < dump.sqlIf it succeeds, the error is resolved. If it still fails:
- Increase to 512M or 1G: --max_allowed_packet=512M
- Check if your query or file is truly larger than expected
- Review application logs for the exact packet size being sent
For persistent application errors, update your application connection string or driver configuration if it supports max_allowed_packet parameters.
Advanced notes
Memory Allocation: MySQL allocates max_allowed_packet memory only when needed, so setting it high (512M–1G) is generally safe for modern systems. Replication: If using MySQL replication, ensure both the source and replica have matching max_allowed_packet values to avoid sync failures. Cloud Databases: For RDS, Aurora, or managed MySQL, update the parameter group (not my.cnf). Use AWS RDS console or equivalent to modify max_allowed_packet. Optimization: Rather than always increasing max_allowed_packet, consider chunking large imports into smaller SQL files or using batch INSERT statements within the limit. For applications, stream large BLOBs in chunks instead of sending entire objects in one query. Docker/Containers: If using MySQL in Docker, pass the option via MYSQL_INIT_COMMAND or mount a custom my.cnf. Testing: In development, set max_allowed_packet to match production values to catch packet size issues early. Connection Pooling: Some application drivers (Node mysql2, PHP mysqli) support max_allowed_packet in connection strings—configure it once rather than per-query.
Frequently asked questions
- What does "1153" mean?
- MySQL enforces a maximum size limit on individual network packets exchanged between the client and server. This limit, controlled by the max_allowed_packet system variable, prevents network overload and resource exhaustion. When your application sends a query, INSERT statement, or binary data that exceeds this limit, MySQL rejects it with ERROR 1153 and closes the connection.
- How do I fix "1153"?
- MySQL rejected a data packet that exceeds the max_allowed_packet limit. Increase the max_allowed_packet setting in your MySQL configuration or pass it as a command-line option to handle larger queries, BLOB uploads, or database dumps.
- What causes "1153"?
- The max_allowed_packet value (default 16-64MB) is smaller than the data packet being sent Importing a SQL dump with rows larger than the limit Sending a single SQL statement or query exceeding the limit
- Is the "1153" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚MySQL Official Documentation
- 📖MySQL 8.0 Packet Too Large Reference(Official Docs)
- 📖MySQL Error Reference 1153(Official Docs)