Hello friends, welcome to calnetguide.com. In today’s article, we are going to focus on fixing some WordPress site error thus, WordPress error establishing a database connection. In my previous articles, I have covered a lot topics which ranges from blogging, Facebook security, Payoneer, computer maintenance and others.
So, today, I decided to focus on WordPress site and its related errors in order to assist people that may have encountered this WordPress error establishing a database connection error message or people that are likely to encounter it in the future. This is because provided technology is involved, different kinds of errors will come up from time to time, and the only way to help ourselves have better use of technology is not to be scared of these errors, but rather to find solutions to them.
So, the actual inspiration behind this article is to assist people who are seeking for solutions to WordPress error establishing a database connection issue, so as to help them maintain a healthy experience in the use of technology and be able to tackle related errors that may come up in the future.
WordPress Error Establishing A Database Connection
If you are a website developer, a blogger, a website owner or even a website visitor, there may have been a time or several times you tried accessing a certain website and then, unexpectedly see an error message thus, WordPress error establishing a database connection or simply error establishing a database connection. In situations like this, you are just left in a state of perplexity, you are wondering what this could mean. At that time, if you are just a visitor to the website, you might just be discouraged and go off to another website as you have concluded that the particular website is no longer available, this is usually the case.
Now, this WordPress error establishing a database connection becomes something more serious and worrisome if you are the actual owner of the website. You are worried that you website has fallen and that your visitors will no longer be able to reach your site. Yes, it indeed causes a lot of panic because you do not want to lose your traffic, it is very painful to a serious blogger.
Yes, but it is not the end, every problem will certainly have a solution, and so is WordPress error establishing a database connection problem, there is certainly a solution to it. In fact, it is not something you should worry very much about, the most optimal solution is here, I call it best solution 100%.
Now, I will start by explain what WordPress error establishing a database connection is all about, possible causes of this error and how to fix it. So, we proceed below.
Read Also: Blogging As A Career
What is the meaning of WordPress error establishing a database connection?
Before I dive into the explanation of the above error, I would love to explain these keywords:
This will help us have a proper understanding of this error message and enable us to tackle it easily using the steps I will itemize below.
1. What is WordPress?
WordPress is a platform or content management system ( CMS ) which enables people to create different kinds of website and blogs using click and drag options without necessarily having coding skills. This means that WordPress can be used by people that are not core programmers or people that write codes to create websites.
Creating websites and blogs using WordPress is as easy as installation a software in a computer and customizing it to suit your taste. One other interesting thing to note is that over 30% of websites and web applications online are built on the WordPress platform.
Now, let us continue with the next keyword, error below.
2. What is error?
I will define error as an interruption, alteration or failure to complete a particular task. This failure could be caused by use of wrong parameters or an unexpected change in the supposed parameters.
The next term to define is establishing ( to establish ).
3. What does establishing mean?
Establishing is the act or process of actualizing something. So, to establish means to actualize something or to make something to exist.
The next keyword is database.
4. What is database?
Database is a system or software where different kinds of data are stored in an organized manner for easy retrieval.
Now, one thing to understand is that the WordPress system uses a database to store and organize all the contents of your website if your site is built using the WordPress system. These files include your posts, media files, accounts, etc.
The next keyword is connection.
5. What is connection?
Connection means linking up, which implies that to connect to something means to link to it.
Having explained the above terms, I will now go ahead to describe the relationship between the words, WordPress error establishing a database connection.
Now, whenever you come across the notification, WordPress error establishing a database connection, this is exactly what you should know.
The WordPress system uses a database to store all your site data as I had stated earlier. This means that whenever someone tries to access your website or open any of your post, the WordPress systems connects to the database immediately and queries it for that content the person is trying to access. Yes, everything in your WordPress site is stored in MySQL database tables.
Also, whenever you try to login to your website, publish a post or perform any action at all, WordPress system connects to database first before returning any value to you.
From the above explanation, this means that whenever WordPress fails to connect to your website’s database, it will return the error message, WordPress error establishing a database connection or rather, error establishing a database connection. This means that something has altered or interrupted it’s connection, causing the connection to fail.
There are different reasons why the WordPress error establishing a database connection occur, there are many different things that make this happen. So, I will state the possible causes below, after which I will guide you through the process to troubleshoot and fix the error.
What are the possible causes of WordPress error establishing a database connection?
Below are the possible causes of WordPress error establishing a database connection.
1. Wrong WordPress database information or database credentials :
Every database on the internet has its own credentials or login information with which your website interacts with it. These credentials include database name, database username, database password and database server.
So, in a case where any of these information provided in the php configuration file for your WordPress site’s database does not match with the ones associated with your database, the WordPress error establishing a database connection will certainly occur. This happens especially if you just moved your WordPress site to a new host. This can easily be fixed by updating your php database configuration file with the correct details. You will learn how to do this after I have stated all the reasons.
2. Too much Flow of traffic to your site :
I trust you know that each host plan has the amount of resources assigned to it, so if the amount of resources assigned to your host plan cannot handle the amount of traffic flowing to your website or blog, then you are likely to encounter WordPress error establishing a database connection. The solution in this case is to upgrade your host plan, this alone would solve the problem.
3. The database server where your WordPress site’s database is hosted is down :
Now, since your website’s database is hosted on a separate server from your website, there are times the database server go down for one reason or another. In such cases, your website will encounter the WordPress error establishing a database connection issue. In a case like this, you do not have any role to play, the server will come back on its own when everything is alright. You may contact your host to know if your server is working well.
4. Some of your website’s WordPress core files are corrupt :
There are cases where some of your WordPress website’s core files are corrupt, this will certainly cause WordPress error establishing a database connection issue. These corrupt core files are usually caused by failed update of plugins, themes and the WordPress software itself. That is, when you are updating them and they crash along the line. You should always ensure to update your WordPress software, your plugins and themes whenever the updates are available, you should also monitor them as they are updating until they complete.
5. Your database is corrupt :
Now, there are cases where some bad scripts like bad plugins or themes might cause your database to corrupt. Database corruption could also be caused by hackers’ attack on your site. If your database is corrupt, you will surely encounter the WordPress error establishing a database connection. To avoid database corruption, you should be careful with the plugins you install.
You should only install relevant plugins and template needed on your site or blog, then delete any other inactive plugins entirely, it is not advisable to have too many inactive themes ( templates ) installed on your site too. You should only leave one inactive theme installed, that is the default WordPress theme, for example Twenty twenty, twenty-seventeen or any of the twenty’s. Just leave one of them and delete others. Then you should have the active theme you are currently using including the child theme if you created any. That’s all.
But hey, relax, do not panic yet, I don’t think your database is corrupt because it is not usually the case with WordPress error establishing a database connection issue. Just consider the other options first.
Now that I have stated the possible causes of the WordPress error establishing a database connection, let me now guide you through the process to troubleshoot and fix the error.
HOW TO FIX WORDPRESS ERROR ESTABLISHING A DATABASE CONNECTION :
To fix this error, follow the below methods and steps.
To save your time and save yourself from too much stress and panic, the first thing I would suggest you do is to contact your host immediately you notice this WordPress error establishing a database connection.
You should create a support ticket and tell them the error message you are seeing when you try to access your website. You should ask them to check if your database server is running fine, you should then go ahead and ask them to help you fix the error. Your host should be able to fix the error for you immediately.
But if they refuse to help you fix it, because in some cases, there are some issues your host will refuse to help you fix claiming it is a web development error that you should fix yourself or hire a developer to do it for you. If this is the case, then there is nothing to worry about, you can try other options below.
You should go to your cpanel to verify if your database credentials in your php configuration file matches with the one associated with your database. If they don’t match, just put in the correct details and everything will start working fine.
Below are the steps to follow in doing this.
Step 1. Login to the cpanel where your site is hosted and open file manager
Step 2. Go to the root folder of your website, i.e public html folder. In some hosts, if your website is hosted on an add-on domain, then your root folder for that particular site might not be in the public html, it will be in a folder titled yoursitename.com where yoursitename refers to the name of your domain.
Step 3. Locate and right-click on wp-config.php, then select “edit” from the options.
Step 4. You should go to the section where you have the following lines of code
define( DB_NAME, ‘ name of database’ );
define( DB_USERNAME, ‘database username’ );
define( DB_PASSWORD, ‘ password for database’ );
define( DB_Host, ‘ localhost’ );
Step 5. Check and verify that the values for DB_NAME, DB_USERNAME, DB_PASSWORD, and DB_Host, correspond with the ones in your database. If they are not, then edit the details to match the one in your database. Please be careful as you are doing this.
Follow the below steps to verify the details in your database
Step 6. Open control panel in another tab while the wp-config.php file is still open
Step 7. Scroll to the database section on your cpanel and click on MySQL databases
Step 8. You will see your WordPress database alone if your site is the only one hosted in the account, else you will see other database too. You should locate the one that is for your WordPress site.
Step 8. Below your databases, scroll down and you will see your database details including the username and link to change password. Just click on it to verify the details, you may change the password to a new one and denote it.
Step 9. Go back to your wp-config.php file and verify if it matches with the details on your database. If they don’t match, then update the file with the accurate information on your database.
Step 10. You should also check your host information if your dbhost is localhost or something else. You may contact your host company and ask them the exact one used on their host.
Step 11. Click on save.
You should then try to access your website and see if it fixes the WordPress error establishing a database connection issue. If the problem is fixed, congratulations. Else, try these other methods below.
Try To Repair Your database.
You can try to repair your database by using the repair database option on the databases section .
Just select your wordpress site’s database from the list of databases and click on Repair Database.
Alternatively, you may open your wp-config.php and put in the below code
define( ‘WP_ALLOW_REPAIR’, true );
Then save it.
Hence, visit your site through this format, https://yoursite.com/wp-admin/maint/repair.php
It will bring an interface with options to repair database, just click on “repair database”.
After the repair completes, remove back this code define( ‘WP_ALLOW_REPAIR’, true ); from your wp-config.php and save
In some cases, this will fix the WordPress error establishing a database connection issue.
Try to disable your site from accessing plugins and themes, this will help if the WordPress error establishing a database connection was caused by a corrupt plugin or theme.
Follow the steps.
1. Login to your site cpanel, open file manager and go to the root folder of your site
2. Go to wp-content folder and open it,
Then locate the “plugins” folder
3. Just rename the folder to something else, this will stop your site from interacting with the plugins since the path has changed after you renamed the folder.
4. Try visiting your site from another tab and see if it is resolved, you should then know that a corrupt plugin caused the WordPress error establishing a database connection. If it doesn’t work yet, follow the same steps and rename your theme folder and try opening your site.
If you find out that either the theme folder or plugins folder contains a corrupt file, you can delete the contents of the folder and then change back the folder name to the original name. I.e “plugins” or “themes” as the case may be. You can then reinstall few useful plugins since your site is back. After the entire process.
Change to a higher host plan or to a better host company.
Switch to a higher host plan if you have noticed that the WordPress error establishing a database connection is caused by low resources on your host plan or host company.
Contact a professional to assist you.
In this case, the professional will run some checks to find out where the error is coming from, he will then help you fix it.
Read Also: How To Show Hidden Files In Windows 10
With the above explanation, methods and steps I have listed, I believe you have learnt the cause of WordPress error establishing a database connection and how to fix it.
Kindly use the comment box to tell us if any of these methods and steps worked for you.
Tell us which one of them solved your problem.
If you have any further questions, you may go ahead and use the comment box to ask your questions.
Kindly share this post with others too to enlighten them.
Hi friends, I’m Callistus Onyewuchi, the founder of CALNET TECHNOLOGIES and calnetguide.com. I’m a developer, blogger and tech expert; I love music too. I’m here to share my knowledge with you… trust me, you will be glad you came here.