WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My provider's database server recently had some downtime and my site was displaying the classic "Error establishing a database connection" message for about an hour.

I knew what the problem was but realised it would be useful if I was able to replace that message with something a little friendlier (ideally a more verbose message contained within my site's template, so as not to scare users).

My question is: are there any plugins that provide this functionality? Or does this error occur at too low a level for any plugins to be invoked? If so, I'll probably edit the WP core, but it would be nice to use something more pluggable.

Many thanks,


share|improve this question

closed as off-topic by toscho Feb 8 at 1:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 9 down vote accepted


You can make your own Database Error page by adding a db-error.php to your wp-content folder (/wp-content/db-error.php). You can find a good example of such a page in the link above. Don't forget adding header("HTTP/1.0 500 Internal Server Error"); in that file so it get a proper header message.

share|improve this answer
Awesome, I did not know this! Going to get a custom page added to all my sites pronto! – Rick Curran Jan 4 '12 at 0:07
This was exactly what I needed – thank you! – BigglesZX Jan 4 '12 at 13:40

I'm not aware of such a plugin, and will be happy to upvote any appropriate answer.

On the other hand, a way not to display this message is not to have the error any more. On most hosting providers, connections are refused when the maximum number of open connections is reached.

A cache plugin (such a WP Super Cache) will drastically decrease the number of connections and make this error message less frequent.

share|improve this answer
With a caching plugin like WPSuperCache that generates static pages, a site can continue serving pages (at least those in the cache) for a time if the database goes away completely. – Carl Russmann Jan 3 '12 at 22:45

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