MySQL throws the error “Got a packet bigger than ‘max_allowed_packet’ bytes” when the server receives a query larger than the configured packet size.
This usually happens during:
-
Large INSERT or UPDATE queries
-
Importing big SQL dumps
-
Handling large BLOB/TEXT fields
-
Running WordPress/WooCommerce sites with large metadata
-
API-heavy applications with oversized payloads
This error stops the query completely and often breaks backups, migrations, or application functionality.
If you want MySQL experts to handle this safely in production, explore our Linux Server Management or Server Optimization Service.
1. Why This Error Happens
MySQL limits the maximum size of a single packet it can process.
Default values:
-
MySQL: 4MB
-
MariaDB: 16MB
If your application sends a packet larger than that (for example, a massive JSON payload, binary file, or large SQL import), MySQL rejects it and throws:
ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes
This is a server-level limit, not an application bug.
2. Fix: Increase
max_allowed_packet
in my.cnf
Edit:
/etc/my.cnf
Under [mysqld], add or modify:
max_allowed_packet = 256M
Or for high-intensity systems:
max_allowed_packet = 512M
Restart MySQL:
systemctl restart mysqld
MariaDB:
systemctl restart mariadb
Verify value:
mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
3. Fix: Increase Packet Limit for Client Tools Too
If you use:
-
mysql
-
mysqldump
-
phpMyAdmin
-
Adminer
-
API clients
…you MUST update client-side settings as well.
For CLI clients:
Edit:
/etc/my.cnf
Add:
[client]
max_allowed_packet = 256M
4. Fix: For phpMyAdmin Users
Update:
php.ini
Set:
upload_max_filesize = 512M
post_max_size = 512M
memory_limit = 1024M
Restart Apache/Nginx + PHP-FPM.
5. Fix: During SQL Import (mysql or mysqldump)
Run import with packet override:
mysql --max_allowed_packet=512M -u root -p database < backup.sql
For mysqldump:
mysqldump --max_allowed_packet=512M -u root -p database > dump.sql
6. Fix: Repair Corrupted or Oversized Rows
If the error appears mid-query, you may have:
-
A corrupted row
-
A binary BLOB too large
-
A broken JSON entry
-
A huge WordPress meta row
Check largest rows:
SELECT table_name, data_length
FROM information_schema.tables
ORDER BY data_length DESC
LIMIT 10;
Check for large meta rows (WordPress):
SELECT meta_key, LENGTH(meta_value)
FROM wp_postmeta
ORDER BY LENGTH(meta_value) DESC LIMIT 20;
7. Fix: For WordPress & WooCommerce Sites
Common causes:
-
Oversized WooCommerce session rows
-
Broken serialized data
-
Large plugin-generated meta entries
You can clean them:
DELETE FROM wp_options WHERE option_name LIKE '%_transient_%';
DELETE FROM wp_postmeta WHERE meta_key = '_wc_session_expires';
8. Fix: For Applications Using APIs or BLOBs
Check if your app is sending:
-
Huge JSON payloads
-
Large file uploads inside the query
-
Base64 encoded BLOB chunks
Either:
-
Increase packet size
-
Reduce payload size
-
Use streaming instead of full BLOB insert
9. Fix: For MariaDB Users With Large Joins
MariaDB sometimes hits the limit during large temp table merges.
Increase:
max_heap_table_size = 512M
tmp_table_size = 512M
Restart server.
10. Final Checklist
Before retrying:
-
Restart MySQL
-
Verify max_allowed_packet
-
Verify client packet limits
-
Check php.ini if using phpMyAdmin
-
Check application logs
-
Try re-importing with higher limits
With these steps, 99% of packet-related errors disappear instantly.
If you need help fixing this on a production environment, our team handles it under Emergency Server Support.
Conclusion
The “Got a packet bigger than ‘max_allowed_packet’ bytes” error occurs when MySQL rejects a query that exceeds the allowed packet size. Increasing the limit on both the server and client side usually fixes the issue. For persistent problems, review large BLOBs, corrupted tables, or oversized application data.
For safe database tuning, migration handling, or performance optimization, explore our Server Optimization Service or Linux Server Management.


Leave A Comment