Client did not respond to server — connection closed
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.
-- 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.
-- 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.
✕ 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.
ER_CLIENT_INTERACTION_TIMEOUT (4031) was added to provide a more specific error than the generic 2013 (CR_SERVER_LOST) for idle timeout disconnections.
MySQL 8.0.24 — 4031 ER_CLIENT_INTERACTION_TIMEOUT
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev