ER_NET_PACKET_TOO_LARGE means MySQL received or tried to send one communication packet larger than max_allowed_packet. The packet may be a SQL statement, one returned row, a mysqldump INSERT, or a replication event. Fix it by identifying which component is rejecting the packet, raising the server and client limits that apply, and reconnecting or restarting the affected component. MySQL 8.0 documents a 64MB server default, a 16MB mysql client default, and a 1GB protocol maximum.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What the max_allowed_packet error means
MySQL sends data over its client/server protocol in packets. A packet is not limited to a complete result set: a single statement sent by a client, a single row returned by the server, or a binary-log event sent from a replication source can be the oversized item. When either the client or mysqld receives a packet larger than its configured max_allowed_packet, MySQL raises ER_NET_PACKET_TOO_LARGE and closes the connection. Applications often surface the same failure as Lost connection to MySQL server during query.
As an Amazon Associate I earn from qualifying purchases.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsThe limit exists independently on each side of a connection. Raising the server value does not enlarge the buffer in the mysql command-line client, and changing a dump utility does not raise the receiving server’s ceiling. A successful fix therefore starts with the component that reports the error, not with an arbitrary increase everywhere.
Documented reference values
| Component or limit | Documented value | Qualification |
|---|---|---|
| MySQL protocol maximum | 1GB | Largest possible packet in the MySQL 8.0 Reference Manual |
mysqld server default |
64MB | Documented MySQL 8.0 default |
mysql client default |
16MB | Documented MySQL 8.0 default |
mysqldump default |
24MB | Documented MySQL 8.4 utility default |
replica_pending_jobs_size_max default |
128M | Documented MySQL 8.4 replication value |
These are ceilings and defaults, not recommendations for every workload. A game backend storing large save blobs, replay data, screenshots, or JSON documents may legitimately need more than a default, while a small transactional database may not.
#1 Best Overall
Diagnose the failing side before changing anything
- Capture the exact error. Record whether it occurs during an application query, a direct
mysqlsession, a dump export, a dump import, or replication. Preserve the complete message, including whether it saysER_NET_PACKET_TOO_LARGEor only reports a lost connection. - Estimate the largest item involved. Look for one unusually large SQL statement, a BLOB or TEXT value, a row returned by a query, a generated dump INSERT, or a binary-log event. The setting must exceed that one item, not merely the average request size.
- Inspect the server’s global and session values. Run:
SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet';
SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
The global value is the default for new connections. The session value belongs to the current connection, so checking both can reveal a session that was opened before a global change or was configured differently by a client.
- Inspect the client or utility separately. The
mysqlclient,mysqldump, and other connectors have their own communication-buffer settings. A server value that is high enough cannot compensate for a smaller client-side limit. - Check the direction of the packet. A large upload points toward the client sending a statement or value; a large result points toward the server returning a row; a replication failure requires checking both source and replica settings and the replication event size.
Choose a packet size without guessing
Use the largest legitimate statement, row, dump INSERT, or replication event as the baseline. Add room for protocol overhead, especially for replication, where event headers and row-based event encoding can make an event larger than the nominal data value. Do not set the value to the 1GB protocol maximum simply because it is available. The documented maximum is a hard upper bound, not a sensible default.
Free tools Windows power users keep installed
One-click scans. No signup required.
- For a single application request, measure the largest SQL statement and its largest parameter or returned row.
- For imports, inspect the largest INSERT line or row payload in the dump.
- For BLOB and TEXT columns, size for the largest complete row that can be sent or returned, not just the column’s usual value.
- For row-based replication, size for the largest row image sent in an update. All columns and values in the updated row can contribute to the event even when the changed column itself is small.
MySQL allocates extra packet memory only when it is needed. Even so, an unnecessarily high ceiling makes worst-case memory use harder to control, so choose a value tied to a real workload and review it when the schema or data format changes.
Use the same units consistently
Option files and startup arguments accept human-readable suffixes such as 128M. Runtime SQL assignments use a numeric byte value or an arithmetic expression. Treat the two forms as equivalent only after converting them deliberately: 128M is represented as 134217728 bytes in the runtime examples below. Avoid copying a startup command directly into a SQL prompt.
Worked sizing examples
If the largest valid dump INSERT is about 70MB, a 128MB setting leaves room for statement and protocol overhead without approaching the 1GB protocol ceiling. If a row-based replication event can contain a 100MB row image, sizing only for a 100MB nominal value may be too tight; include event headers and encoding overhead and check the pending-job allowance on a multithreaded replica. These examples illustrate the method, not a universal setting. Re-measure when rows, payload formats, or batching rules change.
Apply a temporary server fix
A runtime change is useful for confirming the diagnosis or recovering a service before editing configuration files. Runtime SET syntax takes a numeric byte value or an arithmetic expression; it does not accept startup-style suffixes such as 128M.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →SET GLOBAL max_allowed_packet = 134217728;
The number above is 128MiB expressed in bytes. An arithmetic expression is also suitable:
SET GLOBAL max_allowed_packet = 128 * 1024 * 1024;
SET GLOBAL changes the global setting used for new connections under MySQL’s system-variable rules. Existing sessions may continue using their current session value, so reconnect the application, client, or utility before retesting. A runtime-only change is lost when the server is restarted.
Persist the server setting
Use SET PERSIST when supported
SET PERSIST changes the running value and writes a persistent setting for subsequent restarts:
SET PERSIST max_allowed_packet = 134217728;
Use the same byte-value rule as SET GLOBAL. Verify the result with the SHOW GLOBAL VARIABLES query, then reconnect the workload that failed.
Edit the server option file
Add the setting under the [mysqld] section of the option file used by your installation:
[mysqld]
max_allowed_packet=128M
Option-file and startup syntax accepts the M suffix. The equivalent startup form is:
mysqld --max_allowed_packet=128M
After editing the file, restart the MySQL service or use the installation’s documented reload procedure. Confirm the effective value after the service returns. If the server is managed by a hosting panel, container definition, or system service, make the change in the configuration source that actually starts mysqld; editing an unused file will have no effect.
Fix a command-line mysql client
The interactive mysql client has a separate default and must be started with a value at least as large as the packet it needs to send or receive:
mysql --max_allowed_packet=128M -u USER -p DATABASE
Replace USER and DATABASE with the account and schema you use. Reopen the client after changing the server so the new connection receives the intended session value.
To make the client setting apply to future invocations, put it in an option file:
Rank #3
[mysql]
max_allowed_packet=128M
The client and server values should be compatible. If the client remains at its 16MB default while the server is configured for 128MB, a statement or returned row between those sizes can still fail on the client side.
Fix mysqldump exports and imports
Set the dump utility’s own limit
mysqldump has a separate --max-allowed-packet option. Its documented default is 24MB and its documented maximum is 1GB. For a dump containing larger rows or INSERT statements, set the option explicitly:
Recommended Free Tools
mysqldump --max-allowed-packet=128M -u USER -p DATABASE > backup.sql
This option belongs to mysqldump; it is not the same variable as the server’s max_allowed_packet. The utility cannot override a lower limit on the server receiving or producing the data.
Configure the receiving mysql process for an import
During an import, the process reading backup.sql is the mysql client, so give it a matching or larger value:
mysql --max_allowed_packet=128M -u USER -p DATABASE < backup.sql
The destination server must also have a high enough max_allowed_packet. A common incomplete fix is to raise only mysqldump‘s option: the dump can then be generated, but the import still fails when the destination server or its client rejects an INSERT.
Separate export and import tests
An export can succeed while an import fails because the two operations involve different processes and, often, different servers. Test the export with the mysqldump option, then test the import with the receiving mysql client’s option and the destination server’s value. Record each process’s setting rather than assuming one command controls the entire pipeline.
Repair replication failures
Replication uses the packet limit for messages between a source and a replica. A large TEXT or BLOB value can stop the replication I/O thread if either side is configured below the event size. Check the effective value on both servers rather than assuming the source’s setting controls the replica.
Account for row-based events
With row-based replication, an update event can contain all columns and values for the affected row. A small change to one column does not guarantee a small event. Size max_allowed_packet for the largest row image that can be transmitted, then allow room for event headers and encoding overhead.
Rank #4
Check pending-job memory on a multithreaded replica
On a multithreaded replica, compare replica_pending_jobs_size_max with the source server’s max_allowed_packet. MySQL’s replication documentation recommends setting the pending-jobs limit to at least the source server’s packet limit; the 8.4 manual documents a 128M default for that variable. Event headers and row-based events can make an event larger than the nominal packet value, so a value equal to the source limit may still require review when large rows are present.
After changing replication-related settings, monitor the I/O and SQL threads and verify that the previously failing event is consumed. Do not mask a data-size problem by changing only the replica while leaving the source or the replica’s pending-job allowance below the event size.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteApplication connector checks
When an application reports a lost connection, inspect the connector’s packet or communication-buffer option in addition to the server session. The exact option name varies by connector, so use that connector’s configuration documentation and verify the effective value on a live connection where possible. A connection pool can also preserve sessions created before a global change; recycle the pool or reconnect those sessions before retesting.
Check both directions. A client-side limit can reject a large upload before the server processes it, while a server-side or client-side result limit can fail when one row is returned. If the same operation succeeds with a newly started mysql client but fails in the application, the application-side setting or connection pool is the next place to inspect.
Understand the most common failure branches
The message says “Lost connection to MySQL server during query”
Treat this as a possible packet-size failure when it occurs on one unusually large statement, parameter, result row, or dump INSERT. Confirm the server and current session values, then inspect the client’s own option. If the query is genuinely smaller than both limits, investigate other causes separately rather than continuing to raise max_allowed_packet.
The command rejects SET GLOBAL max_allowed_packet=128M
Runtime SET does not use startup suffix notation. Convert 128M to bytes:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
SET GLOBAL max_allowed_packet = 134217728;
Keep the suffix form for an option file or a mysqld startup argument.
The server value increased but the error remains
- Reconnect the application or command-line client so it receives the new global default.
- Check the client’s own value;
mysqlandmysqldumpdo not automatically inherit the server’s ceiling. - For an import, raise the destination server and the
mysqlreader, not only the export command. - For replication, inspect both source and replica plus
replica_pending_jobs_size_maxon a multithreaded replica. - Confirm that the packet estimate includes the complete row or event and protocol overhead.
The change disappears after a restart
SET GLOBAL is a runtime change. Use SET PERSIST where supported or add max_allowed_packet under [mysqld] in the active option file, then restart or reload according to the installation procedure.
A very large setting appears to solve the error but creates operational risk
Reduce the value to the smallest ceiling that covers the largest legitimate packet with reasonable margin. The protocol allows up to 1GB, but using that maximum for every connection is not a substitute for understanding which row, statement, or event is oversized. Review application batching and dump generation if a single SQL statement is far larger than the workload needs.
The setting is correct, but one operation is still too large
A limit increase is not always the best long-term design. If one generated statement contains many oversized values, reduce the batch size or split the operation where the application, import process, or dump workflow allows it. The packet limit applies to the largest single statement or event, so sending several smaller statements can avoid a single-packet failure without raising the ceiling unnecessarily. Do not split a replication event manually; size replication for the row image MySQL actually generates.
Temporary versus persistent fixes
| Change | Where it applies | Persistence | Connection or restart action |
|---|---|---|---|
SET GLOBAL max_allowed_packet = 134217728 |
Server global default | Runtime only | Reconnect clients that need the new value |
SET PERSIST max_allowed_packet = 134217728 |
Server runtime and persistent configuration | Persists across restart where supported | Reconnect clients that need the new value |
[mysqld] max_allowed_packet=128M |
Server startup configuration | Persistent option-file setting | Restart or reload using the installation’s procedure |
mysql --max_allowed_packet=128M |
One mysql client process |
Only for that invocation | Start a new client process |
[mysql] max_allowed_packet=128M |
Future mysql client invocations |
Option-file setting | Start a new client process |
mysqldump --max-allowed-packet=128M |
One dump process | Only for that invocation | Run the dump again with the option |
A repeatable checklist
- Identify whether the failure is an application query, returned row, dump export, dump import, or replication event.
- Capture the approximate size of the largest legitimate packet.
- Run
SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'andSHOW SESSION VARIABLES LIKE 'max_allowed_packet'on the relevant server connection. - Inspect the separate setting used by
mysql,mysqldump, or the application connector. - Choose a byte value larger than the packet, including replication overhead where applicable.
- Apply a runtime change with
SET GLOBALorSET PERSIST, using bytes rather than anMsuffix. - For a lasting server change, edit the active
[mysqld]option file and restart or reload as required. - Reconnect clients and rerun the exact operation that failed.
- If replication is involved, verify both servers and review
replica_pending_jobs_size_maxon multithreaded replicas. - After recovery, lower an unnecessarily high value and document the packet size that justified the final setting.
Frequently Asked Questions
What is the quickest fix for ER_NET_PACKET_TOO_LARGE?
Identify the failing component, measure the largest statement, row, INSERT, or replication event, then raise both the server and the relevant client or utility above that size. Reconnect existing sessions before testing again.
Why does increasing max_allowed_packet on the server not help?
The client and server have separate limits. The mysql client defaults to 16MB, mysqldump defaults to 24MB, and application connectors may have their own settings. A smaller client-side buffer can still reject a packet even when the server allows it.
Can I use 128M in SET GLOBAL?
No. Runtime SET syntax uses bytes or an arithmetic expression. Use SET GLOBAL max_allowed_packet = 134217728 or SET GLOBAL max_allowed_packet = 128 * 1024 * 1024. The 128M suffix belongs in startup arguments or option files.
Do existing connections receive a new SET GLOBAL value?
The global value becomes the default for new connections. Existing sessions can retain their current session value, so reconnect the application, connection pool, mysql client, or utility before rerunning the failed operation.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →What max_allowed_packet value should I choose?
Choose a value larger than the largest legitimate packet with margin for protocol overhead. For replication, include event headers and row-based encoding. Do not automatically choose the 1GB protocol maximum; an unnecessarily high ceiling complicates worst-case memory management.
Why does mysqldump still fail after I set its option?
The mysqldump option controls that utility only. The server producing or receiving data still has its own max_allowed_packet, and an import also uses the receiving mysql client’s setting. Configure every process involved in the direction that fails.
How large must max_allowed_packet be for row-based replication?
Size it for the largest complete row image that can be transmitted, not merely the column changed by an update. Add room for event headers and encoding overhead, and on a multithreaded replica review replica_pending_jobs_size_max as well.
Is Lost connection to MySQL server during query always a packet error?
No. It can indicate other failures. Suspect a packet limit when the message coincides with one unusually large statement, parameter, returned row, dump INSERT, or replication event. Compare the actual size with the server, session, and client limits before raising the setting further.
The Bottom Line
ER_NET_PACKET_TOO_LARGE is a single-packet limit mismatch, not a general database-size limit. Find the largest statement, row, dump INSERT, or replication event; check the server and the separate client-side limits; then apply the smallest value that covers the workload with overhead. Use byte values for runtime SQL, persist the server setting deliberately, reconnect affected clients, and verify both ends of any replication or import path.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

