4 Best Ways To Fix The Error Establishing A Database Connection On WordPress 2024

Error Establishing a Database Connection On WordPress

Here we are going to talk about the best ways to get rid of Error Establishing a Database Connection error on WordPress. Today when a person or a service company thinks of creating their online presence they choose to create a website and the most trusted platform to create and host a website is called WordPress. It is one of the best options to create a website online. Hundreds of thousands of websites on the internet are hosted by WordPress.

Like any other service, sometimes people using WordPress also face some major issues and errors. One of the most common and irritating errors of WordPress is the Error Establishing a Database Connection on WordPress.

In this blog, we are going to talk about the best ways to get rid of this error. Other than that, we are going to discuss the major reasons behind this error. So stick to the end!

Reasons for the Error Establishing a Database Connection on WordPress

This error can occur because of a lot of different reasons. We have marked the most common reasons for this error to occur. These are:

  • The first reason could be false database information in the settings. Many people don’t take care of this and thus face problems.
  • The next reason is a damaged or Corrupt database. This can easily cause problems and if this is the case it should be fixed immediately.
  • Another most common reason is the down database server. If your database server is down then you should fix it.

If you have underlined the reason in your case then you should move to that particular solution. But if not, then apply the given solutions one by one.

1. Update Your Site’s URL

Whatever the reason is in your case. The simplest thing that you can do to eliminate the Error Establishing a Database Connection on WordPress is to update your site’s URL. You might think that what this is going to do. But trust me sometimes the simplest solution can help you solve a bigger problem.

If you don’t know how to update your site’s URL follow these instructions:

  • Head to the PHPMyAdmin from your account’s dashboard.
  • Then from there select the WordPress database.
  • Then head to the SQL menubar and then enter this:

UPDATE wp_options SET option_value=’YOUR_SITE_URL’ WHERE option_name=’siteurl’

• Provide your site’s URL to your table’s name.

This will update your site’s URL. Now check for errors.

Also Read: How Cloud Computing Is Changing Management?

2. Check if the Server is Not Available

The second solution is based on the most common reason for the WordPress error. This happens when there is a huge load on the server than it can bear. Go to your account dashboard and then to the PHPMyAdmin, then try to connect to the server. If it connects then make a file named connectioncheck.php and insert this code:

<?PHP $link = mysqli_connect(‘localhost’, ‘username’, ‘password’); if (!$link) { die(‘Could not connect: ‘ . mysqli_error()); } echo ‘Connected successfully’; mysqli_close($link); ?>

Upload this file to your website and then try to access it with your browser. If it opens then it means the users have enough permissions to access your site and the problem is not with permissions.

3. Repair the Database

If somehow your database is corrupted or damaged then the best option is to repair the database. This will help you to make your database stable and working again.

If you don’t know the process then follow these instructions:

• Add the given code to the wp-configure.php file:

define(‘WP_ALLOW_REPAIR’, true);

• Then check for the error, if it is gone and the database is repaired then remove the added line from the wp-configure.php file.

4. Use Help Options

If the above-given solutions are not working for you then the last option that remains is to get help from a WordPress expert. The expert will look at your matter and give the best possible solutions for it. The best place to get an expert is to get to codeable and tell your problem. You can reach out to WordPress developers or they will.


These are some of the frequently asked questions about WordPress errors.

How do I fix error codes?

The first thing that you should do is restart your system and then try to see if the error is gone. If the error is more specific then you should search for the exact solution.

What is a database connection?

This connection means the connection that is established between the database and the server.

What does an error establishing a database connection mean?

This error indicates that the files in the database cannot be connected to your server and thus blocking the normal working of the website. Users cannot use the site because the database cannot be reached.


WordPress is one of the best platforms on the internet for websites. But recently many users have complained about the Error Establishing a Database Connection on WordPress. This blog features solutions to fix this particular error. If you are facing this error too then apply the above-given solution! If you know any other effective solutions for this error then tell us in the comments!

Leave a Comment