Start with quick checks: confirm your database details and check for a hosting...
https://remote-wiki.win/index.php/WordPress_Database_Error_Only_on_the_Homepage_but_Admin_Works
Start with quick checks: confirm your database details and check for a hosting outage. If those look fine, move on to deeper fixes, like repairing the database or checking server limits. Contact hosting support if the database remains unreachable.