4031
MariaDBERRORNotableConnectionHIGH confidence

Client did not respond to server — connection closed

What this means

ER_CLIENT_INTERACTION_TIMEOUT (4031) was added in MySQL 8.0.24. It is returned when a client connection idles beyond the wait_timeout / interactive_timeout without sending a query, and the server closes it.

How to reproduce
trigger — this will error
trigger — this will error
-- After the connection has been idle > wait_timeout seconds:
SELECT 1;

expected output

ERROR 4031 (HY000): The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.

Fix

Use connection pool with keep-alive / reconnect

WHEN Application keeps long-lived connections.

Use connection pool with keep-alive / reconnect
-- In my.cnf: extend the timeout
wait_timeout = 600
interactive_timeout = 600

-- In application: use pool with validation query
# Python sqlalchemy:
engine = create_engine(url, pool_pre_ping=True)

Why this works

pool_pre_ping sends a lightweight SELECT 1 before using a pooled connection, detecting stale connections and reconnecting transparently.

What not to do

Set wait_timeout to 0 (unlimited)

Unlimited idle connections exhaust the max_connections limit and waste server resources. Use connection pooling with keep-alive instead.

Version notes
MySQL 8.0.24

ER_CLIENT_INTERACTION_TIMEOUT (4031) was added to provide a more specific error than the generic 2013 (CR_SERVER_LOST) for idle timeout disconnections.

Sources
Official documentation ↗

MySQL 8.0.24 — 4031 ER_CLIENT_INTERACTION_TIMEOUT

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors