The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Custom Database Error Page

Last updated on:

Put a file called "db-error.php" directly inside your /wp-content/ folder and WordPress will automatically use that when there is a database connection problem.

<?php // custom WordPress database error page

  header('HTTP/1.1 503 Service Temporarily Unavailable');
  header('Status: 503 Service Temporarily Unavailable');
  header('Retry-After: 600'); // 1 hour = 3600 seconds

  // If you wish to email yourself upon an error
  // mail("", "Database Error", "There is a problem with the database!", "From: Db Error Watching");


<title>Database Error</title>
body { padding: 20px; background: red; color: white; font-size: 60px; }
  You got problems.

Reference URL


  1. Mudslide Design
    Permalink to comment#

    We have a free plugin to allow templates for the error pages, such as comment submission errors. <a href=””>, let us know what you think of it.</a>, let us know what you think of it.

  2. ChefGaby
    Permalink to comment#

    The only problem I see with this is when your database stops responding for a few minutes.
    If you activate the email notification you’ll get a lots of emails when a single one would have been enough.
    Other then that it’s a great tip.

    • Ben Lacey
      Permalink to comment#

      You could always create a session variable when the email is sent so you only get one email to notify you if there is a problem. Good tip, thanks Chris :)

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed