Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.


Initially I suspected this was related to the Wordpress framework I'm using (Genesis) or to my child theme functionality, but turns out that's not the case as I was able to get this to work in a test environment running on the same framework and child theme.

Possibly this is related to the caching plugin I'm using, W3 Total Cache. If this plugin is not active, then the custom db-error.php file is picked up.

To rephrase my question, has anyone run into this issue with caching plugins being active?


Has anyone successfully been able to replace the default Wordpress database error page with a custom one?

I tried this (add db-error.php under wp-content), but I can't get it to work for some reason:

share|improve this question

2 Answers 2

This works fine for me as db-error.php in wp-content:

Delete the mailer block if you don't want it

<?php header('HTTP/1.1 503 Service Temporarily Unavailable'); ?>

$to = ""; 
$subject = "My Database is down"; 
$message = "My Database is down"; 
$headers = "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/plain; charset=iso-8859-1\n"; 
$headers .= "X-Mailer: php\n"; 
$headers .= "From: \"Admin\" <>\n"; 

<html dir="ltr" lang="en-US">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>503 Service Temporarily Unavailable</title>
        <style type="text/css">
            h1, p {
                font-family: Helvetica, sans-serif;
                font-size: 26px;
                color: #333;
            p {
                font-size: 16px;

            <h1>My Site is taking a nap right now....</h1>
        <p>But really, we're currently experiencing technical issues &mdash; Please check back soon....</p>
share|improve this answer
still getting the default WP one. I wonder if it's related to the way I'm triggering the db connection error page (by entering wrong db info in wp-config)? – IntricatePixels Apr 17 '13 at 2:15
Looks like it's related to the caching plugin I'm using, updated my question. Will post more here as I troubleshoot this some more. – IntricatePixels Apr 20 '13 at 17:58
Then disallow that file to be cached in W3TC. – markratledge Apr 20 '13 at 18:55

This is still the case in 4.2.2. If DB_NAME or DB_USER is wrong, you get the nice "Can't select database" screen from wp-db.php. If DB_PASSWORD or DB_HOST is wrong, db-error.php gets called. Weird.

Without db-error.php, the nice screen gets rendered for all four of the above errors, which is a more consistent user experience (just no webmaster email).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.