WordPress: Fix Error Establishing Database Connection

One of the most common error most of the WordPress users experience is Error Establishing Database Connection which can be caused by different reasons. Since it is one of the most common problem with WordPress so we have decided to cover a guide on how to Fix error establishing database connection.




First we need to know the possible issue that can cause this error establishing database connection. As I told you before that this error can be caused by different reasons like database credentials have been changed or the database server is down. Anyways we will cover different methods to fix error establishing database connection.

Before you proceed with our tutorial to fix error establishing database connection, make sure you have backup of your database.

How to Fix Error Establishing Database Connection in WordPress

Repair the Database

First method is to repair your database but it is only effective if you’re  getting different error wp-admin page and main page of your WordPress site. Like you may be getting this error on wp-admin page “One or more database tables are unavailable. The database may need to be repaired”. To repair the database, add the lines below to wp-config.php file:

define(‘WP_ALLOW_REPAIR’, true);

When done with adding code, open the this link (http://yoursite.com/wp-admin/maint/repair.php) on your browser and click on “Repair and Optimize Database” connection. If this method fixes your issue then fine otherwise continue reading the post to implement other methods.

Check the WP_Config File

The most important file in WordPress is WP_Config which contain database information  etc. Sometimes the error is caused when you change your database username or password but you forget to modify the config.php file. So open the wp-config.php file and check the database name, database username, database password and host and then save it. Now check your blog again. Hopefully the issue will be fixed now. For more detailed guide, check the guide over at WPBeginner.

These were few methods we shared with you to fix error establishing database connection in WordPress.


Leave a Reply

Your email address will not be published. Required fields are marked *