What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Create db-error.php in your active WordPress content directory—usually wp-content/db-error.php—to replace WordPress’s default database-error display. Return HTTP status 500, and keep the page independent of WordPress and the database. This changes what visitors see; it does not fix the connection failure.
Where to put the custom database error page
WordPress looks for WP_CONTENT_DIR . '/db-error.php' when it handles a database error. In a conventional installation, that means wp-content/db-error.php. If the file exists, WordPress loads it for the error display; if it does not, WordPress uses its default display. See the official dead_db() reference.
If your site has a customized content directory, use that active directory rather than assuming it is named wp-content. Create the file using your hosting file manager, SFTP, or deployment process. Do not edit WordPress core files such as wp-includes/functions.php; the content-directory template is the documented customization point.
Create a standalone page and preserve HTTP 500
The template may be loaded while the database is unavailable, so keep it simple: use plain PHP and HTML, and do not rely on WordPress functions, theme templates, plugins, database queries, or assets whose delivery depends on the site working. The following minimal example returns the required error status before sending the page body:
#1 Best Overall
<?php
http_response_code( 500 );
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Temporarily unavailable</title>
</head>
<body>
<main>
<h1>We’ll be back shortly</h1>
<p>This site is temporarily unable to connect to its database. Please try again later.</p>
</main>
</body>
</html>
WordPress’s database-error reference says its default response sets status 500 to discourage search engines from caching the message and advises that custom database messages do the same. Do not replace that status with 200 just because the HTML page rendered successfully.
Use a calm, accurate message, and give visitors a support or contact link only if it works independently of WordPress and its database. Review the file through your normal site deployment process. The template’s purpose is to communicate an outage, not to conceal it from monitoring systems or repair it.
Rank #2
Check that you are editing the right file
db-error.php and db.php are different WordPress mechanisms, despite their similar names.
| File | What it does | For a custom error page? |
|---|---|---|
wp-content/db-error.php |
Provides the display WordPress loads in its database-error path. | Yes. |
wp-content/db.php |
A database drop-in that can replace or extend the global $wpdb object. |
No. It is for database-layer customization, not the visitor-facing error template. |
WordPress documents the distinction in its dead_db() reference, wpdb class reference, and require_wp_db() reference. PHP error-display settings are not a substitute: the wp-config.php handbook explains that database errors are handled by wpdb and are not affected by PHP error-reporting settings.
Rank #3
If the site still cannot connect to its database
The custom page changes only the error visitors see. To address a connection failure, follow WordPress’s common errors troubleshooting guidance:
- Check the database name, username, password, and host in
wp-config.phpagainst the values supplied by your hosting provider. - If those values are correct, ask your host whether the database server is unavailable or the account has reached a database quota.
- Once the underlying issue is fixed, test that the site loads normally and that the custom error page is no longer being served for database failures.
Recovery Mode is a separate feature, not a database-connection recovery mechanism. WordPress describes it as a way to handle some fatal PHP errors during regular page loads, often involving a plugin, theme, or custom code; it is not activated for CRON or background tasks. See the Recovery Mode documentation.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




