Create a Custom WordPress Database Error Page

Usually, you only see the Error establishing a database connection message when you are first setting up a WordPress site.1 But this error message can also show up if you receive a lot of traffic or there is a problem with your web host.

Last Thursday, for example, Network Solutions web hosting experienced database outages on ALL Unix servers. And while the problems were being resolved, visitors to many affected WordPress sites saw a blank white screen with a database connection error message.2 Clearly, a custom page instructing visitors to come back later would have been better. So, how do you setup custom database error pages?

Solution: Create a db-error.php File in Your wp-content Directory

WordPress makes it easy to set up custom database error pages. All you need to do is create an error page called db-error.php and save it directly in your /wp-content/ directory. WordPress will automatically detect that it is there and display it when there is an error.

Tip: Make your custom db-error.php file send you an email whenever it is displayed. That way, you will be aware of all database issues that your web host may be having.

  1. Generally, a database connection error is quickly fixed once all of the credentials for connecting to the database are correct. The four credentials that you need to verify are: DB_HOST (database host), DB_NAME (database name), DB_USER (database username), and DB_PASSWORD (database password). []
  2. All other database-driven applications on these servers also experienced connectivity problems, not just WordPress sites. []
Tags: , , ,


Trackback URL:

Leave a Reply

Want us to work on your project?

Contact us today for a quote. Click here to submit details regarding your project.

If you are making a general inquiry, send an email to

Go Daddy Deal of the Week: Cheap .COM Domains! Offer expires soon!