Understanding and Resolving MySQL Error 1160 (ER_NET_ERROR_ON_WRITE)

Encountering an Error 1160 in MySQL can be a frustrating experience. This error, which corresponds to SQLSTATE 08S01, indicates that there’s been a problem with writing communication packets. Let’s delve into the potential causes and solutions for this issue to help you diagnose and resolve it.

Diagnosing Error 1160 in MySQL

Before diving into solutions, it’s important to understand what might cause this error. Error 1160 could be a result of network issues, server overloads, configuration settings, or even bugs in MySQL. Here are some diagnostic steps:

  1. Check Network Connectivity: Ensure that your network is stable and can handle the required data throughput. Network hardware issues or misconfigurations can disrupt communication between the server and clients.
  2. Server Resources: Verify that your MySQL server has enough resources (CPU, memory, disk I/O) to handle the current workload. High server load can lead to dropped packets and communication errors.
  3. Configuration Settings: Review your MySQL configuration for any settings that may be contributing to the problem, such as max_allowed_packet and wait_timeout.
  4. MySQL Logs: Examine the MySQL error logs for any additional information that might point to the cause of the error.

Solutions for Error 1160

After diagnosing the possible causes, here are several solutions that might resolve the error:

Increasing max_allowed_packet Size

A common cause for communication errors is a packet size larger than what’s allowed by the server. You can increase the max_allowed_packet size in your MySQL configuration:

SET GLOBAL max_allowed_packet=16777216;

This sets the maximum packet size to 16MB. You might need to adjust this value based on your needs.

Adjusting wait_timeout

If connections are dropping because they’re idle for too long, you can increase the wait_timeout value:

SET GLOBAL wait_timeout=28800;

This sets the timeout to 8 hours (default is usually 8 hours, but this can be adjusted as needed).

Disabling Query Cache

According to a CloudLinux support article, the query cache can sometimes cause issues with packet communication in MySQL 5.7. If you’re using query cache, consider disabling it:

SET GLOBAL query_cache_size = 0;

Using skip-name-resolve

DNS resolution issues can also cause communication errors. Disabling DNS resolution with skip-name-resolve in your my.cnf or my.ini file can help:


After making this change, you’ll need to restart the MySQL server.

Checking for Bugs

In some cases, the error could be due to a bug within MySQL. Check the MySQL bug tracker to see if your issue is a known problem with a recommended solution.


Error 1160 in MySQL can be caused by a variety of factors, but with careful diagnosis and the application of appropriate solutions, you can resolve the issue and restore stable communication within your database environment. If after attempting these solutions the problem persists, consider reaching out to the MySQL community or a database professional for further assistance.

Leave a Comment