How to Add a Custom Database Error Page in WordPress


How to Add a Custom Database Error Page in WordPress
Dana Cooper

You ever remember seeing a screen like Error Establishing a Database Connection on your site. This can happen for various reasons, but often users don’t know that their site is down. Also that page itself looks pretty ugly in itself. In this article, we will show you how to customize your database error page in WordPress. We will also show you how to setup a notification for every time your website goes down due to a database error.

How to Add a Custom Database Error Page in WordPress
Jackelyn Cooley

All you have to do is to head over to your website and upload a file named db-error.php to the root of your content folder and that should do the trick. You can also search online for detailed step by step directions but this is essentially the process by which you can set up a custom database error page. Your customers would appreciate the effort that you had taken on their behalf. One tip, you may want to ensure that Google does not index your custom error page otherwise this could well turn out to be the page that customers are directed to. And if you know HTML and CSS you can always design this custom database error page as per your preference. But even if you do not know coding, it should not matter much since you should have been able to set up the error page with ease.

How to create a Custom Database Error page in WordPress?
Eula Moore

<?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
/ If you want to email yourself on an error
// mail(“[email protected]”, “Database Error”, “problem with the database!”, “From: Db Error Watching”);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Database Error</title>
<style>
body { padding: 20px; background: red; color: white; font-size: 60px; }
</style>
</head>
<body>
You got problems.
</body>
</html>

How to Create a Custom Database Error Page in WordPress with Free Template
Shavon Peoples

The bad news is that making this page look good, unless you know HTML, and returning the correct http status code so Google does not index this error page, which can screws up your SEO, is not so simple. First of all when you create a db-error.php, WordPress will use this page and return a http status code 200, which to Google means everything is fine. If Google is crawling your site when this happens that means Google will index your error page instead of your correct home page. This is bad. So to make sure Google does not index your custom WordPress database error page you need to include this at the top of your db-error.php file.

<?php header(‘HTTP/1.1 500 Internal Server Error’); ?>

Create a Custom Database Error Page in WordPress
Yessenia Tellez

As it currently stands, this custom database error page is going to send you an email every single time any WordPress page is requested while the database is down. Especially for highly trafficked sites, this could result in thousands of emails flowing into your inbox. On smaller sites, this isn’t really that big of an issue, but for larger sites it would be cool to get a script that would send only one email for each time the database went down. One way to do this would be to use fwrite to alter a static file with some specific text and then check for it before sending the next email, but this would require all sorts of fiddling that seems extraneous. I’m sure there is a better way of doing it.

Ahmed Mohsin
Laurie Castro

You ever remember seeing a screen like Error Establishing a Database Connection on your site. This can happen for various reasons, but often users don’t know that their site is down. Also that page itself looks pretty ugly in itself. In this article, we will show you how to customize your database error page in WordPress. We will also show you how to setup a notification for every time your website goes down due to a database error.

Think Better
Odelia Arndt

You are commenting using your WordPress.com account.
( Log Out / 
Change )

Primary Menu
Annie Bowen

No upload this file to your WordPress site’s /wp-content/ directory . That all you can easily edit it as per your requirement. If you like to setup a email notification for every time your site goes down due to a database error. Then uncomment (remove //) the following line in the above give code:

Be the first to comment

Leave a Reply

Your email address will not be published.


*