Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Sue Dough
Sue Dough
35,800 Points

Error Establishing Database Connection Hack

Ever had a wordpress site go down? Nothing is worst than your clients/users/members etc seeing an "error establishing database connection".

I want to share a hack with you guys.

You can add a file called db-error.php in your wp-content folder. Add the following snippet at the top of the file.

<?php header("HTTP/1.0 500 Internal Server Error"); ?>

You can then make a static HTML page with inline CSS. You could make a cool page for this error when it comes up.

Do not use us get header or get footer as your site can't connect.

<?php get_header(); ?> 


<?php get_footer(); ?>

Let me know if you have any questions. This is an undiscussed topic but great for building big sites with lots of traffic that can go down.