Error 1160: Got an error writing communication packets

You are viewing an old version of this article. View the current version here.
Error CodeSQLSTATEErrorDescription
116008S01ER_NET_ERROR_ON_WRITEGot an error writing communication packets

Possible Causes

This error tells us that the connection between the server and client was aborted. The most common cause is that the client hard-aborted the connection, without calling mysql_close(). It could also be a problem with the connection to the server, such as a wrong or lost package.

How to Find Out More

The error log may have more information about the cause of the error. Setting the MariaDB server option log_warnings to a value of 4 or above can generate more diagnostic warnings in the error log when there is a problem reading packages:

2024-02-17 12:32:45 5461 [ERROR] mariadbd: Could not write packet: fd: 406  state: 2  errno: 32  vio_errno: 1160  length: 34

How to interpret the above:

  • 20090 is the connection id that got the warning/error.
  • fd: 406 406 is the file descriptor that had a problem.
  • state: 2
  • length: 34 is how many characters the server tried to wrote to the file.
  • errno 32 is the system error code (more below).
  • vio_errno: 1160 is our internal error code from the vio library, which stands for ER_NET_WRITE_ERROR "Got an error writing communication packets".
  • length: -1 is how many characters was reported to be read from the read() system call. -1 indicates failure. If length <= read_length then something broke in the communication.

You can use the perror utility to get a description of system and storage engine errors:

shell> perror 104
OS error code 104: Connection reset by peer

This means the connection was aborted by the application/user.

How to Fix

  • Ensure you have a stable internet connection.
  • Ensure that your applications calls mysql_close() for all open connections before exiting.

See Also

  • perror Getting a description for an error number.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.