wait_timeout
Seconds a non-interactive connection may sit idle before the server closes it.
- Default
28800 (8 hours)- Range
- 1 to 31536000 seconds
- Restart needed
- No
- Default checked on
- MySQL 8.4 LTS
What it does
Interactive clients (the mysql CLI) get interactive_timeout instead. Pools that keep connections longer than this see 'MySQL server has gone away' or 'Lost connection'.
Default value
28800 (8 hours). 28800 seconds (MySQL 8.4).
Check the current value
SHOW GLOBAL VARIABLES LIKE 'wait_timeout'; SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME FROM performance_schema.variables_info WHERE VARIABLE_NAME = 'wait_timeout';
Change it
SET SESSION wait_timeout = 600; -- this connection SET GLOBAL wait_timeout = 600; -- new connections, until restart SET PERSIST wait_timeout = 600; -- new connections, and after restarts
No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When to change it
Lower it to clean up connections leaked by apps; then make the pool's max idle or lifetime shorter than the new value.
What can go wrong
Too short breaks pools and long-running clients that sit idle between batches.
Questions about wait_timeout
What is the default value of wait_timeout in MySQL?
28800 (8 hours). 28800 seconds (MySQL 8.4).
Does changing wait_timeout require a restart?
No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When should I change wait_timeout?
Lower it to clean up connections leaked by apps; then make the pool's max idle or lifetime shorter than the new value.
Back to all MySQL settings, or check the MySQL manual for every option.
Related on SQLly
Check wait_timeout on your own server
SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.