If the WordPress site is unable to temporarily connect to it’s associated database a message is shown reporting the error, informing the visitor.
Such an incident happened to me recently. When connecting to a test website I saw a message:
Error Establishing a Database Connection
Advising visitors of this information is potentially giving more information than is required, indeed for most visitors simply saying that there is a temporary problem and suggesting that they come back later is a better message.
That error message is in wp-includes/functions.php and wp-includes/wp-db.php if you were of the mind to change it in the WordPress core.
But changing the message in the core means that the next time WordPress is updated there is the potential for your modified file to be overwritten.
There is the option to create a custom message. Unfortunately the added file is located at the root of the directory /wp-content and not included with the theme file directories.
Add file named db-error.php to the directory /wp-content
Below is an example file:
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600'); // 1 hour = 3600 seconds
mail("support@example.com", "Database Error", "There is a problem with the database connection!", "From: example.com");
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
<title>503 Service Temporarily Unavailable</title>
<style type="text/css">
h1, p {
font-family: Helvetica, sans-serif;
}
h1 {
font-size: 24px;
color: #d00;
}
p {
font-size: 14px;
color: #333;
}
</style>
</head>
<body>
<h1>Server error!</h1>
<p>There is a problem serving the website - please try again later.</p>
</body>
</html>
Change the content and styling to suit your requirements. Maybe incorporate your theme’s CSS files to add consistency with the website.


