Customize WordPress Database Error Page - 14/02/2024

Easy way to customize the database error message from WordPress

When doing some research for the new version of my Fiber Admin WordPress plugin, I found that in the core code of WordPress, they allow us to override the default Database Error Page. It will tell the whole world that you’re using WordPress and your website is having some problems with the database connection 👎.

Follow clue from WordPress

Luckily, WordPress has feature to allow us to customize this default page. Let’s give it a try!

Follow the instruction I found with CSS Tricks here. I found that we can customize the DB Error page by a file called db-error.php in wp-content. But why this file?

In wp-includes/functions.php, WordPress has a function called dead_db which you can see they will allow us to load custom template for the Database Error Page, the custom template will be named with wp-content/db-error.php.


With db-error.php, we can add inline CSS and customize the content of this page, so it will look different from the default DB Error Page which is applied to all the other WordPress pages.

Some tips I found: