≡ Menu

How to create WordPress Custom Database Error Page

Every wordpress blogger get’s frustrated when things goes wrong. WordPress will show “Error establishing a database connection” when there is a major spike in the database traffic. Mostly this error is due to your webhost. I had experienced once with my webhost. WordPress has a nice new feature which lets you to put custom error message when something goes wrong (see my custom message here ).

WordPress Database custom error page :

Upload a file called db-error.php in your wp-content directory, which will displayed when the database connection fails.

Sample file here, download this file, rename it as db-error.php and upload it to your www.yourdomain/wp-content folder.

How to test it

You can test this feature when you have less traffic, say night time. wp-config.php is the file which has your blog database entry. You can find this file in your root ( www.yourdomain/wp-config.php).

Take a backup of your  wp-config.php first and change some database fields like user name or password, upload it again. Now try to hit your blog. You will be redirected to www.yourdomain/wp-content/db-error.php(check mine here). Make sure you replace you original wp-config.php.

You can also add some php code so that emails will be sent to you when this happens.

{ 0 comments… add one }

Leave a Comment