Fixed a bug: WordPress database connection error

  • The “Database Connection Error” is probably one of the most common and frightening errors that WordPress users can encounter.
  • This error means that your website can no longer communicate with or access the WordPress database.
  • It can be caused by incorrect database information in your WordPress settings, a corrupt database, or an unresponsive database server.
  • The error can also occur if the database server is down or the database files are corrupted.
Updated March 2024This tool will stop these errors and fix common problems: Get it at this link
  1. Download and install the software.
  2. It will scan your computer to find problems.
  3. The tool will then correct the issues that were discovered.

There are several problems that WordPress users can encounter, but the “Database Connection Error” is probably one of the most frightening. There is no doubt that the error is closely related to the “White Screen of Death” (WSOD). It prevents your website from communicating with or accessing its database, resulting in a crash. It is imperative you resolve this problem as soon as possible, as it can negatively impact your sales, traffic, and analytics.

This WordPress error can be resolved in a number of ways. Simply work your way through these solutions to get your site back on track quickly.

Fortunately, we’ll discuss some common reasons for this error today, along with some easy fixes.

Establishing Connection

In order to use a data source with the JDBC driver, you must first establish a connection with it. Data sources are usually a DBMS, a legacy file system, or a variety of other sources of data. There are two classes of JDBC applications:


What causes a database connection error in WordPress?

What causes a database connection error in WordPress?

A database is a piece of software that allows you to store, organize, and retrieve data within other applications. If your WordPress settings are incorrect, your database could be corrupt, or your database server could not handle the data requests.

When someone visits your website, WordPress connects to the database where it stores your website content, as well as other website data.

Wp Connect To Database

MySQL is the most popular database system for connecting and modifying WordPress databases. In PHP, you can connect and modify databases.

A WordPress database connection requires the following information:

  • Database name
  • Login information for the database
  • Password for the database
  • Database Server

A configuration file named wp-config.php keeps this information.

You will see an error message titled “Database Connection Error” if any of these items are incorrect.

The database server may be down, the database files may be corrupted, or incorrect login information could cause this error.

Could Not Connect To Mysql Please Check Your Database Settings

Your Joomla configuration.php file may have either the wrong database username, or it may not be configured correctly and you see a “mysql” error message.

Step-by-step instructions on troubleshooting WordPress database connection errors will be provided.

Repair Database WordPress

There are other fixes that you can try if you don’t have a backup that you can restore. If you don’t have a backup that you can restore, then you can try other fixes.


How to fix a WordPress database connection error

Updated: March 2024

We highly recommend that you use this tool for your error. Furthermore, this tool detects and removes common computer errors, protects you from loss of files, malware, and hardware failures, and optimizes your device for maximum performance. This software will help you fix your PC problems and prevent others from happening again:

  • Step 1 : Install PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista).
  • Step 2 : Click Start Scan to find out what issues are causing PC problems.
  • Step 3 : Click on Repair All to correct all issues.


How to fix a WordPress database connection error

In order to be efficient, we will start by suggesting a method that we believe can resolve the problem quickly. Once we have recommended a solution, we will take you through the process of manually fixing it.

Contact your hosting provider

Your website may have stopped working a minute ago, or even a day ago. Luckily, most quality web hosts provide live chat support these days, which is usually quick and easy.

The first step is to contact the live chat and tell them you are experiencing a “database connection error” (insert any error here) and ask:

  • It is possible for the database server to run without issues, if
  • If the server is not currently experiencing bursts of activity.

You will usually be told exactly what caused your error if you tell them about it.

In addition to this, they will tell you if there are any suspicious activities on your server and if your database is in good shape.

Make sure your plugin or theme files aren’t corrupted

There are many things that can damage your WordPress files.

Connecting WordPress To Database

A MySQL database management system is open-source software that powers WordPress. A MySQL database allows your site to store data and make it accessible for you, which is why you sometimes hear it referred to as a “MySQL database.” A MySQL query is sent to a database when WordPress needs to store, modify, or delete data. This simply means that instructions are sent as to which data should be changed, and how it should be handled.

The site may have gone down when you updated a plugin or theme? Perhaps you connected it to an external service?

This step must be completed if you meet any of these conditions. Ignore it if you did not.

The steps are as follows:

Connect via FTP to your host

If you do not know your username and password for your FTP account, you can find them in your welcome email from your host or by asking a support representative in the chat room.

You can access the WordPress root directory by logging into the server. If you establish a FTP connection, you’ll already be in the WordPress root directory, which is usually “public_html” or “www”. You are usually in the WordPress root if you see subfolders like “wp-content” and “wp-admin.”

In “wp-content”, rename the plugins folder (anything else but “plugins”):
3. Observe if the bug exists on your site again.

Plugins are most likely to be responsible for this problem. In FTP, rename the folder to “plugins.” Enter and change the folder names of each plugin one at a time.

In most cases, adding an underscore at the end makes it easier to identify the troubleshooting plugin. Once you locate the culprit, either remove the plugin or search online for a fix.

  • After renaming the Plugins folder, rename the Themes folder as well if the bug persists.
  • You can rename both plugins and themes folders to “plugins” and “themes” if that doesn’t solve the issue.

Make sure your database isn’t corrupted

Sometimes the WordPress database gets out of control, resulting in an error when connecting to the database. The WordPress database is a pretty complicated thing, and there are a lot of little cogs that need to work perfectly to avoid problems.

  • Check the WordPress dashboard at for any errors.

Alternatively, skip this step if the same general error is shown, “Database connection error.”.

  • You might also be able to find some good tips in WordPress’ troubleshooting service in new versions.

The other possibility is that you are the one who has to “repair” the database if you get a message that starts with “One or more database tables are unavailable […].”.

Download “wp-config.php” from the WordPress root directory to your desktop. First, connect via FTP to your site. Finally, go to your WordPress root directory and open the file.

Just before “Like this, stop editing”, add an extra line to this file using Notepad:

Defining WP_ALLOW_REPAIR as true;

There are several files in WordPress which are essential to the site such as wp-config.php, which contains information about the database.

Overwrite the old file with the new one by uploading the file via FTP.

Your site’s maintenance page can be found at

If you find an error in your site, go back and click the other button.

WordPress Database Errors

Occasionally, your WordPress database can become corrupted as a result of a failed upgrade, a database crash, or a faulty plugin. If your problem isn’t caused by the MySQL server or configuration file, try repairing your database to determine if it is the problem with your database connection.

Is there no problem with any more errors? If not, then you’ll need to return “wp-config.php” to its previous state. Delete the addition and redownload the file.

Check your database login credentials

When connecting to the database, WordPress uses a unique username and password. When you make changes to your site’s files, hosting environment, or other things, strange scenarios can occur. These credentials normally don’t change on their own. Whenever links change, it happens even if it’s not supposed to! In addition, when you enter wrong credentials, a database connection error occurs.

“wp-config.php” contains the fix.

I try to run wordpress on my macbook, and keep getting a error establishing a database connection. I try to write database name, username, password, and leave database host as localhost and leave table prefix as wp_ and seems can’t make connection to database. When I install mamp didn’t give me any error. after that I start the server and tab the ‘Open WebStart page’ and it open ‘http://localhost:8888/MAMP/?language=English’ from here I type http://localhost:8888/wordpress and it open ‘http://localhost:8888/wordpress/wp-admin/setup-config.php?step=0’ I try to follow screen and enter the values that ask to me as I describe above and didn’t make mysql connection. Any idea how to make it to run?

These strings are what we are discussing here:

Defining(“DB_NAME””, “some_db”);
Defining(“DB_USER”, “some_username”);
(DB_PASSWORD, some_password)
(DB_HOST, localhost);

If any of these details are incorrect, WordPress won’t be able to establish a connection with the database.

This problem can be solved manually, however, depending on the host and the interface, it can be very confusing and require several steps. Therefore, we have a better solution for you that is much more universal since whatever we say will only apply to a smaller group of users on the same host as us anyway:

The four lines below can be extracted from the PHP file “wp-config.php”, copied to the clipboard, and then pasted into the chat window to ask your host’s support if they are correct.

Typically, he will let you know exactly what changes have been made when he checks everything.

To change the credentials, simply paste them into your WordPress configuration file (wp-config.php).

DB_NAME = define(some_db); //name of your WordPress database
DB_USER, some_username;
Defining(DB_PASSWORD, some_pass);
Defines the database server web address by by setting the values DB_HOST and localhost.

In the end, download the file again via FTP. If the error has been fixed, you can return to your site.

Restoring the default WordPress files

It may have occurred due to a hacking attempt, a mistake making some changes to files, or possibly a malicious plugin altering the file.

There’s always the option to restore the default WordPress source files, which is usually done by copying over the current version of WordPress from to the new one.

Unzip the downloaded file. Remove the “wp-content” folder from the unzipped archive.

When you finish the upload, check your site to see if the issue has been resolved. This is the last resort to resolve the issue. Log in via FTP and download the new WordPress files. Overwrite the old files.

It will be necessary for you to contact your web host’s support team again if it doesn’t work. Tell them everything you’ve done and ask for help if that doesn’t work for you. The host has now been given the opportunity to resolve the problem after you’ve pretty much exhausted all your options.


RECOMMENATION: Click here for help with Windows errors.

Frequently Asked Questions

  1. Contact your hosting provider.
  2. Make sure your plugin or theme files are not corrupted.
  3. Make sure your database is not corrupted.
  4. Check your database links.
  5. Restore WordPress default files.

A "database connection error" is probably one of the most common and scariest errors that WordPress users can encounter. This error means that your website can no longer communicate with or access the WordPress database, causing the entire website to crash.

With phpMyAdmin, you can also easily import your WordPress database. Simply run phpMyAdmin and select your WordPress database. Then you need to click on the "Import" link on the top menu. On the next screen, click "Select File" and then select the backup file of your database that you downloaded earlier.

The "Database Connection Error" problem may be caused by incorrect database information in your WordPress settings, a corrupt database, or a non-responding database server. A database is a software that allows you to easily store, organize, and retrieve data in other software.

Website | + posts

Mark Ginter is a tech blogger with a passion for all things gadgets and gizmos. A self-proclaimed "geek", Mark has been blogging about technology for over 15 years. His blog,, covers a wide range of topics including new product releases, industry news, and tips and tricks for getting the most out of your devices. If you're looking for someone who can keep you up-to-date with all the latest tech news and developments, then be sure to follow him over at Microsoft.