Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#11570 closed enhancement (wontfix)

Change Default Database Error Page

Reported by: GuruXL Owned by: ryan
Milestone: Priority: high
Severity: normal Version: 2.9
Component: Database Keywords: dev-feedback close
Focuses: Cc:


As a dynamic blogging system, WordPress consists of PHP files (the WP core) that interact with a MySQL database to generate the web pages for your website. When everything is working properly, this dynamic interaction keeps WordPress humming along like a champ, but when your database crashes, WordPress can’t operate and will deliver the following message to your visitors:

Error establishing a database connection

I think it’s safe to say that the default database error message:

  • is ugly
  • is useless to visitors
  • is useless to site admins
  • reveals sensitive information

A default message should be generated that gives information that the site is down and doesn't reveal information.

<?php // custom WordPress database error page tutorial @

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

<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>Captain, the ship can&rsquo;t take much more of this!</h1>
		<p>Perishable Press is currently experiencing technical issues &mdash; Please check back soon!</p>

Change History (7)

#1 @dd32
12 years ago

  • Keywords dev-feedback added; dbase database error removed
  • Milestone changed from 2.9.1 to Future Release
  • Type changed from defect (bug) to enhancement

The original intention of the blank error was to enforce to end-users that it was their database as the reason for failing to load, and not a) WordPress or b) Something else they may have absolutely no clue over

It at least points end users in the right direction.

On a production website, You'd want to redefine the Maintainence and Database error pages to something custom.

I cant find the original tickets related to the Dead DB pages to link right now...

Milestone: Setting to Future Release pending a patch and/or agreement that something needs to change for 3.0. Changing to enhancement rather than defect, as its enhancing an already present functionality, Even if thats to hide extra information.

#2 @sirzooro
12 years ago

If you want to send email in such situation, it should be done in smarter way. Proposed solution may flood admin email box, especially on busy sites.

#3 @mrmist
12 years ago

Yeah, an email might be desired in some cases, but without the database being available to authenticate and/or track such things it could easily be used as a basis for DOS or similar.

#4 @scribu
12 years ago

  • Keywords close added

Sending an email is a bad ideea. Serious sites should instead do regular pings from an external system.

Even if it did send an email, I don't see what useful information WP could send to the site admin, other than info related to the visitor.

#5 @hakre
12 years ago

Please enable database logging with the WPDB component to get alerts about database problems. You can help improve that component to enable better logging (incl. sending out emails) so that it better integrates with the php error_log function. For more information about PHP and error logging please see: php error_log function. Currently WPDB only supports logging to file and the syslog.

#6 @johnbillion
12 years ago

Suggesting close as wontfix.

A custom database error file can be set at wp-content/db-error.php to give visitors nicer error messages. Apart from some styling or wording changes, not a lot can be done to improve the default error message.

#7 @nacin
12 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I meant to comment to this ticket, but I never did. Instead, I sent an email to as the tutorial ( has a rather fatal flaw, in that the custom db-error.php file does not check for ABSPATH, and therefore can be hit with an HTTP request and an email is sent. It also doesn't use wp_mail, or status_header, etc. But I digress.

I'm closing this as wontfix. It is already customizable via db-error.php and there are no valid reasons to change the default.

Note: See TracTickets for help on using tickets.