How to fix ERROR 1156: Got packets out of order in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 23, 2025ยท 288 views

MySQL Error 1156 occurs when network packets between client and server are received out of sequence, disrupting protocol communication. This typically stems from network instability, protocol mismatches, timeout issues, or configuration problems.

Quick fix

Fixes 1156

ping <mysql_host>
traceroute <mysql_host>
nslookup <mysql_host>
  1. Verify your network connection stability
  2. Increase max_allowed_packet setting
  3. Check and increase timeout settings
  4. Fix MySQL Shell protocol mismatch (if applicable)
mysql โ€” error
ping <mysql_host>
traceroute <mysql_host>
nslookup <mysql_host>
ERROR 1156: Got packets out of order

What this error means

MySQL Error 1156 (SQLSTATE 08S01) indicates a critical communication failure in the MySQL wire protocol. The server expects packets to arrive in a specific sequence; when they arrive out of order, the protocol handler cannot properly reconstruct the message. This usually means either the network connection is corrupted, the client-server versions are incompatible, a firewall is interfering with packets, or the connection has timed out silently. The server cannot continue processing queries until the connection is reset.

Typical symptoms

  • MySQL connection suddenly drops with "Got packets out of order" error
  • Large INSERT or UPDATE operations fail mid-transaction
  • SSH tunneled MySQL connections fail with packet sequencing errors
  • Concurrent queries cause the error to appear occasionally
  • Error appears in MySQL error log: "[Note] Got packets out of order"
  • Web applications fail with "MySQL server has gone away" after this error
  • Connection pooling or persistent connections start failing

Common causes

  1. Network instability causing packet loss or reordering between client and server
  2. MySQL Shell connecting with wrong protocol (X protocol fallback to classic protocol mismatch)
  3. Connection timeout on either server or client without proper reconnection handling
  4. Firewall or proxy server interfering with MySQL packet flow
  5. Client and server using incompatible MySQL versions or protocol versions
  6. max_allowed_packet setting too small for the data being transferred
  7. wait_timeout or interactive_timeout exceeded mid-transaction
  8. SSH tunnel or VPN connection dropping packets
  9. Running multiple concurrent queries on a single non-thread-safe connection

How to fix "ERROR 1156: Got packets out of order"

1Verify your network connection stability

Check network connectivity between your client and MySQL server. Use network monitoring tools like ping, traceroute, or nslookup to ensure the connection is stable:

bash
ping <mysql_host>
traceroute <mysql_host>
nslookup <mysql_host>

If running MySQL over SSH, verify the SSH tunnel is stable:

bash
ssh -v user@host  # Check for connection drops

High latency or packet loss here is a primary cause of this error.

2Increase max_allowed_packet setting

If the error occurs during large data transfers, increase the max_allowed_packet size. Edit your MySQL configuration file (typically /etc/mysql/my.cnf or /etc/my.cnf):

ini
[mysqld]
max_allowed_packet=256M

[mysql]
max_allowed_packet=256M

Also set it in your MySQL client configuration. Restart the MySQL server:

bash
sudo systemctl restart mysql

Verify the setting took effect:

sql
SHOW VARIABLES LIKE 'max_allowed_packet';
3Check and increase timeout settings

Verify your wait_timeout and interactive_timeout settings. Connect to MySQL and check current values:

sql
SHOW VARIABLES LIKE '%timeout%';

The default is 28800 seconds (8 hours) in MySQL 5.7+. If your operations take longer, increase these in my.cnf:

ini
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000

Restart MySQL and verify the changes applied. Consider whether your client should also have matching timeouts.

4Fix MySQL Shell protocol mismatch (if applicable)

If using MySQL Shell, always explicitly specify the protocol to avoid automatic X Protocol fallback:

bash
# Specify the classic MySQL protocol explicitly
mysql --protocol=TCP -u user -p -h host

# Or using URI format with MySQL Shell 8.0+
mysqlsh mysql://user:password@host:3306

Upgrade to MySQL Shell 9.0+ which fixes this issue automatically. For MySQL Shell 8.0 and 8.4, explicitly including the protocol will resolve the error.

5Verify client and server version compatibility

Ensure your MySQL client version matches or is compatible with your server version. Check versions:

bash
# Client version
mysql --version

# Server version (connect first, then run)
mysql -u root -p
SHOW VARIABLES LIKE 'version%';

If versions differ significantly, upgrade the client libraries:

bash
# On Ubuntu/Debian
sudo apt-get update && sudo apt-get install mysql-client

# On CentOS/RHEL
sudo yum update mysql-community-client

For language drivers (PHP, Node.js, Python), ensure they use compatible MySQL connector versions.

6Disable firewall or proxy temporarily for testing

If you have a firewall, load balancer, or proxy between client and server, temporarily disable them to test if they're causing packet reordering:

bash
# For UFW on Ubuntu
sudo ufw disable

# For iptables
sudo iptables -F

# For firewalld
sudo systemctl stop firewalld

Test your connection:

bash
mysql -u user -p -h host

If the error disappears, reconfigure your firewall to allow MySQL port 3306 properly instead of blocking/reordering packets.

7Fix connection pooling and concurrent query issues

Ensure you're not running multiple concurrent queries on a single connection. Each connection should handle one query at a time:

javascript
// Node.js with mysql2 - WRONG: concurrent queries
connection.query('SELECT ...', callback1);
connection.query('SELECT ...', callback2);  // Causes packet ordering

// CORRECT: use connection pool or await
const pool = mysql.createPool({ /* config */ });
pool.query('SELECT ...', callback1);
pool.query('SELECT ...', callback2);  // Pool handles separate connections

For persistent connections, ensure they're being reused properly and not timing out between requests.

8Verify connection details in configuration files

Double-check that your database connection configuration has correct values:

ini
# my.cnf or connection config
[client]
host=localhost
user=mysql_user
password=secure_password
port=3306
database=mydb

Common mistakes:
- Wrong hostname (ensure it resolves correctly)
- Using wrong port (MySQL defaults to 3306, not 3307)
- Credentials not matching actual user
- Network host not allowed in MySQL user permissions

Test with explicit connection:

bash
mysql -h localhost -u mysql_user -p -D mydb
9Restart the MySQL server and client

If all else fails, restart both services to clear any stuck connection states:

bash
# Restart MySQL server
sudo systemctl restart mysql

# Or on some systems
sudo service mysql restart

# Verify it's running
sudo systemctl status mysql

For your application, restart it as well:

bash
# For Node.js apps
pm2 restart app

# For PHP/Apache
sudo systemctl restart apache2

# For systemd services
sudo systemctl restart yourapp

This clears stuck connections and allows fresh negotiation of protocol parameters.

Advanced notes

MySQL Error 1156 is often a symptom rather than the root cause. The underlying issue is almost always network-related or a protocol mismatch. If errors persist after these steps, enable MySQL general query log to see exactly where queries fail: SET GLOBAL general_log = 'ON'; SET GLOBAL log_output = 'TABLE';. Check performance_schema.events_statements_history. For production systems experiencing frequent "Got packets out of order" errors, consider implementing connection pooling (like ProxySQL) which can absorb client connection issues and maintain clean server connections. Monitor with tools like Percona Monitoring and Management (PMM) to catch packet loss and latency issues before they cause errors.

Frequently asked questions

What does "1156" mean?
MySQL Error 1156 (SQLSTATE 08S01) indicates a critical communication failure in the MySQL wire protocol. The server expects packets to arrive in a specific sequence; when they arrive out of order, the protocol handler cannot properly reconstruct the message. This usually means either the network connection is corrupted, the client-server versions are incompatible, a firewall is interfering with packets, or the connection has timed out silently.
How do I fix "1156"?
MySQL Error 1156 occurs when network packets between client and server are received out of sequence, disrupting protocol communication. This typically stems from network instability, protocol mismatches, timeout issues, or configuration problems.
What causes "1156"?
Network instability causing packet loss or reordering between client and server MySQL Shell connecting with wrong protocol (X protocol fallback to classic protocol mismatch) Connection timeout on either server or client without proper reconnection handling
Is the "1156" 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