WordPress 2.3+ official support for custom database error page

Some time ago a tutorial was posted on 5ThirtyOne which addressed customizing the DB Error page rendered whenever visitors landed on heavily trafficked WordPress site. Since then, the method has been proven "useless", ushered away by recent updates to the WordPress code base; more specifically with the release of WordPress 2.3.2 (current release is 2.3.3). Whereas the previous method required manipulating code within a core WordPress file, the new updated method allows for the custom page to be stored externally of the WP root directory. To get started creating your own custom WordPress database error page, follow the two steps below:

Create a db-error.php file in /wp-content/

First things first. Create an XHTML file called db-error.php and upload it to the WordPress /wp-content/ directory.

DB Error file in Transmit

Because visitors will see this page when your WordPress driven website is experiencing database connection errors, you will need to make sure the file includes any style attributes inline, or reference an external stylesheet (absolute URL).

<style type="text/css">...your CSS goes here...</style>


<link href="http://url.com/my-stylesheet.css" rel="stylesheet" type="text/css">

For the sake of simplicity, we’ll create a custom database error page with a single XHTML document including any style attributes inside the <head> tags. The following is the message skeleton originally created and used in the tutorial here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>My server crashed, please call the next of kin</title>
<style type="text/css">
body {
font-family: arial, verdana, sans-serif;
font-size: 62.5%;
background: #fff;
color: #333;
text-align: center;
a {
text-decoration: none;
outline: none;
#error_wrapper {
font-size: 1.3em;
margin: 5em auto 0;
text-align: left;
width: 333px;
.content_wrapper {
padding: 1em 0.7em 0;
<div id="error_wrapper">
<div class="content_wrapper">
<p>It looks as though my server has taken an unsupervised leave of absence. I may not know of its whereabouts so would you be so kind as to notify me via <a href="mailto:admin@domain.com" title="Send me an email">email</a>?</p>

Second step, there is none

If you created a standard XHTML document and dropped the code in db-error.php inside the /wp-content directory, there really isn’t anything else to do other than to ensure that your site visitors never see a WordPress database error page while visiting your site.

Discuss - 6 Comments

  1. That’s pretty cool. Of course, those who are uninformed will just blame you for having crappy hosting and using WordPress anyway. But it’ll still be cool to have a different kind of error than the usual. Another way to remind people of you ๐Ÿ˜€

  2. Neil says:

    Now that’s handy; I didn’t even know the error DB page was essentially hard-coded into the WordPress core (and, therefore, a clean slate at every update).

    Now I just need the traffic with which to bring my database to it’s knees, and to give my DB error page a chance to show itself to the world!

  3. […] official support for custom database error page handig wp trucje (tags: tutorial database wordpress) Stem of voeg toe aan : […]

  4. […] the easiest things are potentially the most useful. Derek at 5ThirtyOne has written a tutorial on creating a custom database error page. Apparently this feature is now hard-coded into wordpress 2.3.2 and above, making this super […]

  5. milo says:

    Every time I come here, I am learning something new, thanks Derek.

  6. […] 2.3+ is officially supporting database error page. Via 5 Thirty […]