If you are running a WordPress blog then you might have encountered this most common WordPress Error :“Error Establishing a Database Connection”.

This Error occurs when the WordPress is disconnected with the Database.It mostly occurs, when your webhost could not withstand too many simultaneous connections or something went wrong in wp-config.php file.

Very often If you encounter this error then It is time to look for better WebHost.

Lets come to the point,You know what went wrong but you must convenience your users to revisit your website after sometime.

So here is a hack to spice up your Database Error Page.

Open your Text Editor and paste the following code



header(‘HTTP/1.1 503 Service Temporarily Unavailable’);

header(‘Status: 503 Service Temporarily Unavailable’);

header(‘Retry-After: 600′);

// mail("admin@email.com", "Database Error", "Database Error", "From:  Database Error Watcher");





<title>Database Error</title>


#error {

font-family: "Times New Roman", Times;

font-size: 30px;


margin: 0;










<div id="error">

Sorry for the Inconvenience.Check back later.





Now Save it as db-error.php and Upload to your blog’s wp-content / folder

If you want to receive a Email notification about Database Errors then simply uncomment the line no. 5 and replace default Email address with yours.


Now you can test this code by Temporarily altering your database details in wp-config.php.I have tested it and works flawlessly.

Note : Take a backup before editing wp-config.php to avoid any mishap.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge