I think this is one of the most known pages on the internet maybe. We all know it – the Error establishing a database connection page. WordPress has changed the last period and works much better, there are tons of optimization plugins, caching and so on so database servers are less needed and this page is less visible these days.

Anyway, having a cool website means customizing most part of it and this one is no exception. Actually, this is a pretty ugly page which nobody made an effort to customize and prettify. In this tutorial we’ll show you how you can customize this page and make your website… exclusive.

Create a new page

Open your code editor and create a new file and save it as “db-error.php”. Copy and paste the code below in this file you have created.

<?php // custom WordPress database error page

header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 600'); // 1 hour = 3600 seconds


<title>Database Error</title>
body { padding: 20px; background: red; color: white; font-size: 60px; }
Website is currently down.

Now, that we have a file with the contents above you’ll need to save it. After being saved, we’ll need to upload this into our WordPress directory. Start your FTP client and navigate to the /wp-content/ folder. Upload the file you just created here.

Add an email notification

You can even set an email notification once this page has been shown to any user. In order to do it, you will need to add the code below into the file, right before the last header() line. Note: this will send you email every time this page is shown. If many visitors see it, your email will be flooded with emails from your server.

// If you wish to email yourself upon an error
mail("your@email.com", "Your website is Down - Database Error", "There is a problem with the database!", "From: Database Error Watching");

That is all. Don’t forget to share this tutorial with your friends and we hope you enjoyed reading this. If you found it useful, you can subscribe to our Facebook and Twitter pages.