How to fix ERROR 1153: Got packet bigger than max_allowed_packet in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 23, 2025· 158 views

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";
  1. Check your current max_allowed_packet value
  2. Identify the actual packet size you need
  3. Temporarily fix via MySQL command (no restart)
  4. Permanently fix via my.cnf configuration (recommended)
mysql — error
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

  1. The max_allowed_packet value (default 16-64MB) is smaller than the data packet being sent
  2. Importing a SQL dump with rows larger than the limit
  3. Sending a single SQL statement or query exceeding the limit
  4. BLOB/TEXT field containing data larger than the configured limit
  5. Network packet fragmentation or large binary data in INSERT statements
  6. Client-side max_allowed_packet differs from server-side value

How to fix "ERROR 1153: Got packet bigger than max_allowed_packet"

1Check your current max_allowed_packet value

Log into MySQL and run:

sql
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.

2Identify the actual packet size you need

Check your largest SQL file or BLOB size:

bash
# 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 apps

A safe approach is to set max_allowed_packet to 256M or higher for production systems handling substantial data.

3Temporarily fix via MySQL command (no restart)

For immediate relief without restarting MySQL:

sql
SET GLOBAL max_allowed_packet = 256 * 1024 * 1024;  -- 256MB
SET GLOBAL net_buffer_length = 16 * 1024 * 1024;    -- 16MB

Verify the change:

sql
SHOW VARIABLES LIKE "max_allowed_packet";

Note: This resets when MySQL restarts, so use it only for temporary fixes or testing.

4Permanently fix via my.cnf configuration (recommended)

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):

ini
[mysqld]
max_allowed_packet = 256M
net_buffer_length = 16M

[mysql]
max_allowed_packet = 256M

Note: Both [mysqld] (server) and [mysql] (client) sections need the setting if you're importing via command-line. Restart MySQL:

bash
# Linux/Mac
sudo systemctl restart mysql

# Or on macOS with Homebrew
brew services restart mysql

# Windows
net stop MySQL80
net start MySQL80
5Fix via command-line for specific imports

If you only need to import a one-time large dump, pass max_allowed_packet to the client:

bash
mysql --max_allowed_packet=256M -u root -p database_name < huge_dump.sql

For mysqldump restoration:

bash
mysqdump --max_allowed_packet=256M -u root -p database_name > backup.sql
mysql --max_allowed_packet=256M -u root -p database_name < backup.sql

This avoids permanent configuration changes for one-off operations.

6Verify the fix works

Re-run your import or query:

bash
mysql --max_allowed_packet=256M -u root -p database_name < dump.sql

If 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