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

WordPress is by far the most popular content management system (CMS) in the world. It powers almost 30% of an entire Internet, but it doesn’t mean that the platform is flawless. On the contrary, WordPress-based websites occasionally face certain issues, with error establishing a database connection being one of the most frequent problems. It’s a big deal for various reasons:

 

  • The error webpage is nothing more than a dead end
  • It chases visitors away because it’s useless
  • The problem damages website authority
  • It could be a sign of hacker attacks

 

000webhost.com has a really nice article that gives solution to this problem, however let’s see how we can make your website attractive to visitors when having this issue. The best way to minimize this problem is to create a custom database error page in WordPress. In this post, we will show you how to do that.

 

How Does It Work?

WordPress is almost fully automated and it’s also how the system deals with database connectivity problems.

 

Mary Elliott, a web design specialist at Best Essays, explained it concisely: “When WordPress cannot connect to the database, the CMS will immediately look for the custom error page to show it to the visitors. But if you don’t create such page, WordPress will display the default option.”

 

This is not good because users get to see an ugly picture:

 

 

Plain text on white background is probably the last thing an average webpage visitor should see. For this reason, you should design a custom database error page.

 

How to Fix the Problem?

Although WordPress is more or less automated, it still takes a little bit of coding to design a custom database error page. To do this, you need to make a file called “db-error.php”. In this file, you need to insert the following code lines:

 

<?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 wish to email yourself upon an error

// mail(“your@email.com”, “Database Error”, “There is a 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>

 

This way, you can set up a special page to replace the default and boring solution. If you don’t want Google to index your error page and undermine website credibility, you should add an extra line:

 

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

 

Use a Template to Solve the Issue

If coding is too difficult for you, you can find an easier option – use a template to make a custom database error page in WordPress. For instance, Coming Soon offers a bunch of interesting designs, including 400 thousand images you can choose from!

 

When creating this page, we recommend you take a few things into consideration:

 

  • Add a company logo to increase brand awareness
  • Include functional links to other posts that match the interest of your visitors
  • Add URLs to your social media accounts
  • Tell users that you are making upgrades to improve website performance
  • Add subscription forms to send visitors an email when the problem is resolved.

 

CONCLUSION

Error establishing a database connection is not uncommon on WordPress-powered websites, but it can seriously jeopardize your online credibility. If you want to minimize the problem, you should create a custom database error page. In this post, we showed you how to do it with just a little bit of coding or using a free template.

 

Do you deal with this problem often? Do you think it harms your business and how do you solve it? Let us know about your experiences in comments, we would be glad to exchange interesting ideas with you!

Rate this post

Hopefully you'll come back soon!
Get More Stuff
WordPress Multilingual, Performance, SEO, Reviews and HOT Deals. One email per week!
Stay Updated
Close
GET MORE STUFF
IN YOUR INBOX
WordPress Multilingual, Performance, SEO, Reviews and HOT Deals. One email per week!
Stay Updated
adipiscing velit, Praesent luctus suscipit lectus Aenean

Pin It on Pinterest

Do you find this interesting?

Share it with your friends!