Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

MySQL raises ER_NET_PACKET_TOO_LARGE when one SQL statement, returned row, or replication event is larger than the packet limit on the server or the client. Fix it by identifying which component is rejecting the packet, sizing max_allowed_packet for the largest legitimate statement or row, and raising the server and client-side limits together. Reconnect clients after a server change; use a persistent option-file or SET PERSIST change when the increase must survive a restart.

What the max_allowed_packet error means

MySQL sends data over its client/server protocol in packets. A packet can contain a complete SQL statement sent to the server, a single row returned to a client, or a binary-log event sent from a replication source to a replica. The limit applies to the largest individual packet, not to the total size of a transaction, dump file, or result set.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When either mysqld or a MySQL client receives a packet larger than its configured max_allowed_packet, MySQL emits ER_NET_PACKET_TOO_LARGE and closes the connection. Applications that do not expose that exact error often show the less specific message Lost connection to MySQL server during query. The latter message can have other causes, so confirm the packet-size error in the server log, client output, or replication status before changing configuration.

Why one oversized row is enough

A table can contain millions of small rows and still work until one statement, BLOB, TEXT value, generated dump INSERT, or replication event crosses the limit. Conversely, a modest-looking statement can produce an oversized returned row. Measure the largest single unit that crosses the connection; do not size the setting from the database’s total size.

Documented limits and defaults

These figures come from the Oracle MySQL 8.0 and 8.4 Reference Manuals. They describe defaults, not a recommendation for every workload.

Component Documented value What the value controls
MySQL protocol 1GB largest possible packet Upper protocol limit; no configuration can make a packet larger than this.
mysqld server 64MB default Maximum packet accepted or generated by the server.
mysql command-line client 16MB default Maximum packet buffered by that client process.
mysqldump 24MB default; 1GB documented maximum for --max-allowed-packet Packet size used by the dump utility. This is separate from the server variable.
replica_pending_jobs_size_max 128M documented default in the replication discussion Pending-event memory limit on a multithreaded replica; it is not a replacement for max_allowed_packet.

The server, mysql client, and mysqldump settings are independent. A server increase cannot enlarge a client buffer, and a dump option cannot override a lower limit on the receiving server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run this diagnostic sequence first

  1. Reproduce the failure. Record whether it occurs during an application query, an interactive mysql session, a dump export, a dump import, or replication. Save the complete error text and estimate the size of the statement, row, BLOB/TEXT value, dump INSERT, or replication event that triggered it.
  2. Read the server’s global value. Connect with an account that can inspect system variables and run:
    SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet';
  3. Read the current session value. In the same connection that fails, run:
    SHOW SESSION VARIABLES LIKE 'max_allowed_packet';

    The session result tells you what that connection is using; the global result is the default applied according to MySQL’s system-variable rules for new connections.

  4. Inspect the client or utility separately. The mysql client and mysqldump each have their own communication-buffer setting. Check the command line, option files, wrapper scripts, container environment, or driver configuration that actually starts the failing process.
  5. Identify the largest legitimate packet. For a query, inspect the largest literal or parameter value. For a result, inspect the largest row returned. For a dump, locate the largest generated INSERT. For replication, determine the largest row image or binary-log event, including protocol and event overhead.

Do not skip the client check. It is common to raise the server and continue receiving the same error because the process that sends or receives the packet still has a smaller buffer.

Choose a safe target value

Set the value above the largest packet that the workload must carry, with practical headroom for protocol framing and, in replication, event headers. The target must remain at or below the 1GB protocol maximum. A value that is merely larger than the average row is not sufficient when an occasional row or statement is much larger.

For application queries and results

Use the largest real request or returned row as the baseline. If an application deliberately stores large documents or images in BLOB columns, include the encoded or serialized form that crosses the connection, not just the source file’s nominal size. If only one endpoint sends large values, its client-side setting still has to accommodate the packet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For imports and exports

Use the largest single INSERT statement in the dump, not the dump file’s total size. A multi-gigabyte dump can succeed when every statement is below the limit; a small dump can fail if one row is unusually large.

For replication

Size both source and replica for the largest event. With row-based replication, an update event includes all columns and values for the updated row, even when the changed column itself is small. A multithreaded replica also needs enough replica_pending_jobs_size_max to queue the event; event headers and row-based event data can make an event larger than the nominal packet value.

Raise the server value temporarily

For a quick test or an emergency import, change the global value at runtime with an integer number of bytes:

SET GLOBAL max_allowed_packet = 134217728;

The example sets 128MiB (134,217,728 bytes). Runtime SET syntax uses a numeric byte value or an arithmetic expression; it does not accept startup-style suffixes such as 128M. After changing the global value, establish a new client connection so that the client receives the new server default where applicable. Existing sessions can continue using the value they already negotiated.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To change the running value and write a persistent setting on MySQL versions that support it, use:

SET PERSIST max_allowed_packet = 134217728;

SET GLOBAL is a runtime change. SET PERSIST additionally records the setting for later server starts. Use the command allowed by your MySQL version and operational policy, and verify the result with SHOW GLOBAL VARIABLES.

Make the server setting persistent in an option file

Add the setting under the [mysqld] group in the option file used by that server:

[mysqld]
max_allowed_packet=128M

Startup configuration accepts the M suffix. The equivalent startup option is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqld --max_allowed_packet=128M

After editing the option file, restart the MySQL service or use the installation’s documented reload procedure. The exact file path and service command depend on the operating system, package, and installation layout, so confirm which option file the running instance reads before editing. At startup, validate the effective value with:

SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet';

MySQL allocates extra packet memory only when it is needed. Even so, select a limit from the largest legitimate statement, row, or event rather than setting an arbitrary value near the protocol maximum.

Raise the mysql client limit

Start the command-line client with a value at least as large as the server’s target:

mysql --max_allowed_packet=128M -u USER -p DATABASE

You can make the setting automatic for that client by placing it in an option file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[mysql]
max_allowed_packet=128M

The option-file group is [mysql], not [mysqld]. If a wrapper, service, container, or IDE launches the client, make the change in the configuration that process actually reads. A successful interactive connection does not prove that an application driver has the same limit; each driver can expose its own packet or buffer setting.

Fix mysqldump exports and imports

mysqldump has a separate --max-allowed-packet option. Its documented default is 24MB, and its documented maximum is 1GB:

mysqldump --max-allowed-packet=128M -u USER -p DATABASE > backup.sql

For an import, configure the receiving mysql process as well:

mysql --max_allowed_packet=128M -u USER -p DATABASE < backup.sql

The dump utility’s option controls the utility’s own communication buffer. It cannot override a lower max_allowed_packet on the server receiving the statements. For an import, therefore, check all three points: the value used by the dump file’s producer if an export is failing, the value used by the importing client, and the receiving server’s global value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When an export fails

If the export process reports a packet error while reading rows, raise the mysqldump option and confirm the server can produce the largest row. If the server itself rejects a request, changing only the dump command will not help; raise the server value as well.

When an import fails

If the import stops on one large INSERT, start mysql with a matching or larger value and verify the target server’s global setting. The dump file’s total size is irrelevant to this particular limit; the failing statement is the unit that must fit.

Handle replication-specific failures

max_allowed_packet limits messages between a replication source and replica. A large TEXT or BLOB value can stop the replication I/O thread when either side is configured too low. Raise and verify the setting on both servers, then reconnect or restart the affected replication component according to your replication procedure.

Account for row-based events

Row-based replication sends all columns and values for an updated row. An update that changes a tiny status field can still produce a large event when the row contains substantial BLOB or TEXT columns. Size the packet limit for the largest complete row image, not only for the column your application changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check multithreaded replica queue memory

On a multithreaded replica, set replica_pending_jobs_size_max to at least the source’s max_allowed_packet. A documented 128M default for this variable may be insufficient when the source accepts a larger packet. Event headers and row-based event structure can make an event larger than the nominal packet value, so leave headroom rather than matching the two numbers exactly.

After changing replication settings

  1. Confirm the effective max_allowed_packet on the source and replica.
  2. Confirm the pending-job memory limit on a multithreaded replica.
  3. Check replication status and the I/O thread error text.
  4. Retry or resume the failed operation using the replication procedure appropriate to your topology; do not skip or manually discard an event simply to get the thread running.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the common incomplete fixes

The server was raised, but the same client still fails

Inspect the failing process’s own setting. The command-line client, dump utility, and application driver do not automatically inherit a larger server buffer. Start the process with its packet option or update the option file it reads, then create a new connection.

The client was raised, but the server still rejects the packet

Read SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet' on the destination server. A client-side value can be larger than the server’s value, but the server remains the hard ceiling for statements and returned data. Raise the server temporarily or persistently, subject to the protocol maximum and available memory.

SET GLOBAL max_allowed_packet=128M fails

Runtime SET does not use startup suffix syntax. Supply bytes instead:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SET GLOBAL max_allowed_packet = 134217728;

Keep max_allowed_packet=128M for an option file or startup command, where the suffix is valid.

The error appears only during one large row

That pattern is consistent with a single-packet limit. Find the exact row or value, then size the setting above it with headroom. Do not raise the limit solely because the table or database is large; total database size does not determine packet size.

The application reports only a lost connection

Check the server error log and the application or driver log for ER_NET_PACKET_TOO_LARGE. If no packet error is present, investigate other causes of a dropped connection instead of assuming max_allowed_packet is responsible. A generic lost-connection message is not proof of an oversized packet.

The change disappeared after restart

A SET GLOBAL change is a runtime change. Put the value in the server’s [mysqld] option group or use SET PERSIST on a supported version, then verify the setting after restart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The server becomes unstable after a very large increase

Reconsider the target rather than jumping directly to 1GB. Extra packet memory is allocated when needed, but a high ceiling can permit unexpectedly large requests. Measure the largest legitimate row or event, reduce the setting to a value with reasonable headroom, and address application behavior that creates oversized statements.

Verify the repair

Use the same path that failed, not just a new interactive test. A complete verification has four parts:

  • Read the server’s global value and the current session value.
  • Read or print the client, driver, or utility value used by the failing process.
  • Repeat the exact query, dump operation, or replication workload that previously failed.
  • Confirm that the connection remains open after the largest statement or row completes and, for replication, that the I/O and worker threads continue processing.

If the operation still fails, record which side rejected the packet and compare its effective value with the measured packet size. This prevents repeatedly changing the wrong component.

Operational checklist

  • Identify whether the packet is a statement, returned row, dump INSERT, or replication event.
  • Check both SHOW GLOBAL and SHOW SESSION values on the relevant connection.
  • Check the separate setting for mysql, mysqldump, or the application driver.
  • Choose a target above the largest legitimate packet, with protocol and replication-event headroom.
  • Use byte values for runtime SET; reserve M suffixes for startup and option-file syntax.
  • Reconnect clients after a server change and persist the value if it must survive a restart.
  • For replication, size source, replica, row images, and multithreaded pending-job memory together.
  • Retest the original failing operation and verify that the connection or replication thread stays healthy.

The durable fix is not simply a bigger number. It is matching the server, client, dump utility, and replication queue to the largest packet the workload legitimately produces, while keeping the setting below MySQL’s 1GB protocol maximum.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.