While using WordPress, you might encounter a number of errors. Some can affect your system and some can be ignored easily. If you are getting an error establishing a database connection, then you need to resolve it immediately otherwise your website will not appear online.
In this blog, we will describe how can you resolve “error establishing a database connection”. But, before jumping into how to fix the establish database connection error. You need to know how this error comes into your WordPress website.
Database error issue might arise because of incorrect login username and password. If username and password has been changed recently, then you are not able to access your database with old names. Thus, you need to confirm the login credentials while entering it.
You need to check that WordPress database is working or not. It might be corrupted because of several reasons like installing a faulty or incompatible plugin. Secondly, your hosting server may be down.
Check all the files in your WordPress to resolve the error. If you do any change in any file of WordPress, then make sure it does not affect the process of database connection else restore the file.
Your site may be hacked or down due to heavy traffic. Thus, always select high-quality hosting provider for preventing this issue.
These can be some reasons to get an error in your WordPress website. After knowing the reason of error, you are required to fix it. Here are some steps given below which will help you fix this error and get your site back up online.
You need to check that your database is working or not. If you find your website is normal and get an error while trying to access the WP-admin page or get an error message like one or more tables are not available. Then you need to repair the database. With the WordPress built-in features, you can easily recover your WordPress website.
define( ‘WP_ALLOW_REPAIR’, true )
Once you write line, you are able to optimize your database. After that, you will have to navigate to
You will see this type of page format:
Note: The Repair and Optimize database error takes more time to recover as compared to simple Repair Database. Thus, you can choose the first option.
Great…you have recovered your database error.. If error still exists then go to next step:
To open the WordPress dashboard, you need to use correct username and password. But, if you do any change in your hosting files, WP-config files or anything else then there might be possibility that you are not able to open your WordPress dashboard. With wrong access credentials, you will get a message that “error establishing a database connection”.
To resolve this issue you are required to check the wp-config file: It is the most important file in your entire WordPress installation and it will play a major role for WordPress to connect your database. If you change any password in your WordPress like root password, then you will have to change in the wp-config file
Here are the some steps given below:
Now, you need to check the database host vale, it might be local host or not. Depending on the distinct host, it will vary. You can find the host value by visiting the website of a particular host.
If suddenly your WordPress website stops working then the problem can be on your web host’s end. At that time, you need to immediately contact your web host provider through phone , email support, and live chat and tell them you’re experiencing an “error establishing a database connection”. They will either let you know what the cause is exactly, or they will even fix it for you by providing better solution to fix the error.
If fault is not from the hosting end then they are not able to fix the issue. Then, proceed to the next step:
You may get an error message due to some corrupted files in WordPress like you have updated WordPress theme or plugins or you hooked the site up to an external service.
To fix this issue, you need to follow below steps:
Now, check the WordPress site if there is still an error then go to the theme folder and do the same process which you have done with plugins.
Because of some hacking attempts, some WordPress files can be corrupted then you may face an error like “error establishing a database connection”. Then, you may restore some default file and can establish the database connection. Also, if you have gone for html to WordPress conversion, then make sure it is error free.
We suggest you before choosing WordPress for your website, firstly choose quality hosting provider.
Hope, above steps provided by us would be helpful for you to resolve your issue related to WordPress error. If still you face any issue for WordPress development then you can reach out to CSSChopper without any second thought. Here, you will find a WordPress support team which will help you fix your issue with an error establishing a database connection.