Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Error 1158: Got an error reading communication packets

Error 1158 diagnostic reference: communication packet read errors, client abort causes, log_warnings≥4 diagnostics, error log parsing, and perror output.

Error Code
SQLSTATE
Error
Description

1158

08S01

ER_NET_READ_ERROR

Got an error reading communication packets

Possible Causes and Solutions

The server returns this error when reading from a client connection fails: the connection was closed or reset while the server was waiting for the client's next packet. The client usually never sees the error, because the connection is already gone. You find it in the error log instead, as the reason of an Aborted connection warning. The server writes that warning with the default log_warnings of 2 or higher, and counts the connection in the Aborted_clients status variable:

2026-10-23 13:37:58 31 [Warning] Aborted connection 31 to db: 'shop' user: 'app' host: 'localhost' (Got an error reading communication packets)

The most common causes are:

  • The client program ended, or was killed, without closing its connections, for example an application that exits without calling mysql_close() or the close method of its connector.

  • Something between the client and the server closed the connection: a firewall, load balancer, or NAT gateway that drops idle connections, or a network failure.

  • A connection pool kept connections open that were then cut off, and the server notices when it next reads from them.

To solve the error:

  • Make the application close its connections before it exits, and make the connection pool validate connections before it reuses them.

  • If a network device drops idle connections, let the pool close idle connections before the device's own idle timeout, or enable TCP keepalive on the client. On the server side, wait_timeout closes idle connections cleanly.

  • Check whether the warnings come from one host or user. That points to the application or network path involved.

Related errors:

  • If the server stops waiting because a timeout runs out, such as wait_timeout or net_read_timeout, the reason is error 1159, Got timeout reading communication packets, not this error.

  • If the client sends a packet larger than max_allowed_packet, the reason is error 1153, and the client gets the client error 2006 (HY000): Server has gone away.

  • If writing to the client fails, the reason is error 1160.

How to Find Out More

Setting log_warnings to 4 or higher also writes a low-level warning for each failed read:

How to interpret the above:

  • 20090 is the connection id that got the warning/error.

  • fd: 4575 4575 is the file descriptor that had a problem.

  • state: 1 shows that the file is open. Anything else means the file is not active. Note that in some cases MariaDB will try to abort a read on a file descriptor by closing it.

  • read_length: 4 is how many characters the server tried to read from the file.

  • errno 104 is the system error code (more below).

  • vio_errno: 1158 is our internal error code from the vio library, which stands for ER_NET_READ_ERROR "Got an error reading 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:

This means the connection was reset by the other side, the client or a network device between the client and the server.

See Also

  • perror Getting a description for an error number.

This page is licensed: CC BY-SA / Gnu FDL

Last updated

Was this helpful?