# Error 1160: Got an error writing communication packets

| Error Code | SQLSTATE | Error                     | Description                                |
| ---------- | -------- | ------------------------- | ------------------------------------------ |
| 1160       | 08S01    | ER\_NET\_ERROR\_ON\_WRITE | Got 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](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/server-management/server-monitoring-logs/error-log.md) may have more information about the cause of the error.\
Setting the MariaDB server option [log\_warnings](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/ha-and-performance/optimization-and-tuning/system-variables/server-system-variables.md#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:

* `5461` 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](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/clients-and-utilities/perror.md) Getting a description for an error number.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
