You might have seen database error page in WordPress. It appears during database connection errors showing you a simple message in H1:- Error Establishing a Database Connection, in your website.
You can easily customize it, create a new file “db-error.php” and paste the following code:
<?php // custom WordPress database error page
header(‘HTTP/1.1 503 Service Temporarily Unavailable’);
header(‘Status: 503 Service Temporarily Unavailable’);
header(‘Retry-After: 600’); // 1 hour = 3600 seconds// If you wish to email yourself upon an error
// mail(“your@email.com”, “Database Error”, “There is a problem with the database!”, “From: Db Error Watching”);?>
<!DOCTYPE HTML>
<html>
<head>
<title>Database Error</title>
<style>
body { padding: 20px; background: red; color: white; font-size: 60px; }
</style>
</head>
<body>
You got problems.
</body>
</html>
No upload this file to your WordPress site’s /wp-content/ directory . That all you can easily edit it as per your requirement. If you like to setup a email notification for every time your site goes down due to a database error. Then uncomment (remove //) the following line in the above give code:
// mail(“your@email.com”, “Database Error”, “There is a problem with the database!”, “From: Db Error Watching”);