For **Django >= 4.1** you can enable [persistent connections][1] with [health-checks][2]
```
DATABASES = {
'default': {
'CONN_HEALTH_CHECKS': True,
'CONN_MAX_AGE': 60, # <= Mysql `interactive_timeout`/`wait_timeout`
}
}
```
As result for each db request Django will ping database to check "if connection is alive" (DatabaseWrapper.is_usable) and if not -> Django will close connection
[1]: https://docs.djangoproject.com/en/4.2/ref/databases/#persistent-database-connections
[2]: https://docs.djangoproject.com/en/4.2/ref/settings/#conn-max-age
For **Django >= 4.1** you can enable [persistent connections][1] with [health-checks][2]
```
DATABASES = {
'default': {
'CONN_HEALTH_CHECKS': True,
'CONN_MAX_AGE': 60, # <= Mysql `interactive_timeout`/`wait_timeout`
}
}
```
As result for each db request Django will ping database to check "if connection is alive" (DatabaseWrapper.is_usable) and if not -> Django will close connection
[1]: https://docs.djangoproject.com/en/4.2/ref/databases/#persistent-database-connections
[2]: https://docs.djangoproject.com/en/4.2/ref/settings/#conn-max-age