I manage a site that got a sudden and unexpected increase in traffic. Because of that, there are database access timeouts, with the "Error Establishing Database Connection" message.

This is not a configuration problem, but a 'load' problem. I have installed a caching plugin to help, which has helped somewhat.

What I would like to do, while still trying to mitigate traffic levels, is to change the message that is shown on the screen. Is there a filter or a template that can be used to change that error message.

Note that my question is not related to database authentication problems, but how to put up a message other than the one shown, or to redirect to a more 'static' page (that the caching plugin can help with). The hosting location cannot provide additional resources, and I don't want/need to change to a more powerful and expensive hosting solution.

1 Answer 1


Basically, if you create a PHP file named db-error.php and put under /wp-content/, you'll get what db-error.php will have. Here is my template on CodePen.

This is example :


    header('HTTP/1.1 503 Service Temporarily Unavailable');
    header('Status: 503 Service Temporarily Unavailable');
    header('Retry-After: 3600'); // 1 hour = 3600 seconds
    mail("[email protected]", "Database Error", "There is a problem with teh database!", "From: Example.COM");

<html dir="ltr" lang="en-US">
        <title>503 Service Temporarily Unavailable</title>
        <style type="text/css">
            h1, p {
                font-family: Helvetica, sans-serif;
                font-size: 24px;
                color: #333;
            p {
                font-size: 14px;
        <h1>Uff, you came and our server started to sink!</h1>
        <p>You did nothing wrong. We are sad but our server's condition is just bad out of load. Please check back after sometime.</p>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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