Fixing the „Error establishing a database connection“ error in WordPress yourself

Isabell Bergmann
28. August 2026
100 % reviews written by real people
Titelbild Fehler beim Aufbau einer Datenbankverbindung

When accessing your WordPress website, do you get a White Screen of Death with the error message „Error establishing a database connection“? This is one of the most common website errors and can (usually) be fixed quickly.

Fehlermeldung Fehler beim Aufbau einer Datenbankverbindung

So don't worry: This guide will show you step-by-step how to fix the „Error establishing a database connection“ error.

To test the various proposed solutions for your website, you need:

  • Access to the WordPress Hosting your website
  • Depending on the host: FTP access
  • Depending on the hoster: Access to phpMyAdmin

Below, we discuss the solutions for the various causes of the error message. In the vast majority of cases, it is due to incorrect database user credentials in the wp-config.php file. We will start with that right now!

Note 💡: We recommend that before you start with the various troubleshooting options, you Backup of your WordPress website to create.

Incorrect database user credentials stored in the wp-config.php

We regularly help our customers resolve the "Error establishing a database connection" error. In 98 % of support cases, website owners receive this error message due to incorrect database credentials in the wp-config.php file.

The "wp-config.php" file is a standard file found in the root directory of every WordPress installation.

In the "wp-config.php" file, you'll find four database settings that must match the database you're using. If any of the four settings don't match, you'll see the White Screen of Death on your website.

1. Database Name

Datenbankname wp-config.php

2. Database Username

Datenbank Benutzername wp-config.php

3. Database Password

Datenbank Passwort wp-config.php

4. Your database's hostname

Datenbank Hostname wp-config.php

In summary, the information for the database that wp-config.php wants to access looks something like this:

Datenbank wp-config.php

Instructions: Check and Update User Information

To check the user data for accuracy, you now need access to:

  • Your wp-config.php file, which is located in the root directory of your website
  • The user data in your WordPress website's database

Note 💡: We'll show you how to configure the database user settings in your WPspace hosting dashboard. You don't need FTP access to do this.

1. Check the database information in wp-config.php

In the first step, you copy the database data from the wp-config.php in order to be able to compare it with the „real data“ afterwards.

Log in to your website's WordPress hosting account and navigate to "Files" using the menu on the left. You are now in your website's root directory.

By default, you'll now select the "httpdocs" folder. There, you'll find the required "wp-config.php" file.

Website Dateiverzeichnis

Click on wp-config.php to open it. There you will find the „Database settings“. Securely save the complete section regarding the database settings in a Word document or similar.

Database Angaben

2. Check database names and users

After you have successfully copied the data from wp-config.php, the first step is to compare the database name and username.

To do this, go to the "Databases" menu item. If you have multiple databases here, scroll down to the database with the name (DB_NAME) specified in wp-config.php.

Here, compare the DB_NAME and DB_User with the information in the database. In most cases, this is the cause of the problem.

Datenbankangaben vergleichen

✅ If these match, you do not need to update the DB_NAME and DB_USER in the wp-config.php

❌ If these do not match, this is the cause of the error on your website
Then copy the name and username of the database that belongs to your website in your hosting control panel into your Word document.

3. Check database password

Next, we check the database password and host. To do this, we navigate to the user management in the „Databases“ menu item.

Datenbank Hosting

There you will find an overview of all database users available in your hosting plan. Again, find the matching user based on the details in the wp-config.php. Click on the user.

Datenbank Daten prüfen

The database server is specified in wp-config.php under ‚DB_HOST‘.

Copy the password from the copied data and enter it here in the database user form. Confirm by clicking the „OK“ button.

✅ If the DB_HOST settings in wp-config.php match, no changes need to be made.

❌ If the DB_HOST does not match, this is the cause of the error on your website
Copy the DB_HOST into your Word document so you can adjust it right away in the wp-config.php.

4. Modify the settings in wp-config.php

Note 💡: This step is only necessary if the data between the database user details and the wp-config.php do not match.

Use "Files" to navigate back to your httpdocs folder. Open the wp-config file there.

Now replace the incorrect data with the correct information from the database and confirm by clicking „Save.“.

5. Test website

After you've made the change in wp-config.php, you should be able to access your website normally again. If the error persists, I recommend trying the next suggested methods!

Deleted Database

Did you just find out during testing that your database is no longer there? Then that is a cause of the error when accessing your website.

Without the database, WordPress cannot access any data. And thus it cannot serve any data either.

To fix the error, I recommend restoring a backup of your database. If you haven't created your own backups, check to see if your web host creates regular backups for you.

WPspace creates daily backups of your website, which are available to you for 14 days. Simply select the most recent backup and restore it. If there is still no database, select the next oldest backup from the overview and continue in this manner.

Repairing a Damaged Database

It is very unlikely that your database or the tables it contains are corrupted. However, this can happen in rare, exceptional cases.

When your website is accessed, a connection is established to your database. An error occurs when attempting to read and display the tables/data from the database. As a result, your website cannot be displayed.

If this rare situation has occurred for you, you have the following three options for repairing your database.

Repair database via hosting control panel

As WPspace and therefore Managed WordPress Hosting As a customer, you have access to the „Check and Repair Database“ feature right within the hosting control panel. This tool saves you from having to go through complicated workarounds and allows you to check right away whether your database is even corrupted. Here’s how easy it is to check and repair your database:

  • Log in to your WPspace Hosting Dashboard one
  • Go to the "Databases" menu item„
  • In the overview, click "Check and Repair" in the submenu for the database associated with your website
Funktion Überprüfen und reparieren

✅ Do you receive a Success message: „Database has no errors“ Your database is not corrupted. Therefore, you do not need to repair it. A corrupted database is not the cause of the error message „Error establishing a database connection.“.

❌ Do you receive No success message, your database is corrupted. The built-in function will then automatically repair your database for you.

Repairing a Database Using phpMyAdmin

If the "Repair Database" feature isn't available natively in your hosting account, you can also follow these steps using phpMyAdmin. Here's how to repair your website's database using phpMyAdmin:

Datenbank reparieren phpMyAdmin
  • Access your database via phpMyAdmin
  • Check the box next to „Select all“ to automatically select all tables
  • Open the „flagged“ dropdown menu“
  • Select "Repair Table"
  • The SQL command is now executed automatically.

Repairing the Database Using WordPress

As an alternative, you can also repair your database using WordPress. In my opinion, this is the most complex method. With the instructions below, you’ll be able to follow this method without any problems:

1. Access your root directory:
Access the root directory of your WordPress website either directly via your hosting control panel or via FTP access

2. Open the wp-config.php file
You can find the „wp-config.php“ file in the root directory of your websites. Open this file.

Note 💡: Depending on the host, it is necessary to download the wp-config.php and upload it again after making changes. Locally on your PC, you can then edit the TXT file with programs like Notepad++ (Recommendation) or Sublime Text edit.

3. Add a line of code

Insert the following line of code into the wp-config.php:

define('WP_ALLOW_REPAIR', true);

4. Open the WordPress database repair page
You can use the following prefix to access the WordPress database repair page: /wp-admin/maint/repair.php

In summary, the link looks something like this:

https://deinedomain.de/wp-admin/maint/repair.php

Important: Replace yourdomain.com with your actual domain.

5. Repair database
After clicking the link, the WordPress repair page appears. Here you click on the „Repair Database“ button. WordPress will now automatically repair your database for you.

Remove line 6 of code
Navigate back to your wp-config.php. Search for the line you added there (the easiest way to do this is to use CTRL+F and paste „define(‚WP_ALLOW_REPAIR‘, true);“). Delete the line from the file again and save the updated wp-config.php.

7. Check the website
Open your website in an incognito tab and check to see if the "Error establishing a database connection" has been resolved.

Check the availability of your database server

There are factors that you generally cannot influence directly. These include the availability of your hoster's database server.

If you click on a reliable WordPress hosting providers like WPspace ...this usually happens very rarely, if at all. In 2024, WPspace had an annual average uptime of 99.9 %! 🚀

However, if you suspect that your hosting provider's database server is the cause of the error message, there are several ways to check whether the database server is accessible.

Note 💡: The database server may be unavailable, but the "main server" that hosts your website is available.

  • Check the hosting provider's status page
    A status page is used to keep customers informed about current outages, service limitations, and maintenance work. A professional hosting provider keeps this overview up to date at all times.
    You can find all the information about your status at WPspace via this link: WPspace Status (statuspage.io)
    Tip: You can often set it up so that you're automatically notified of updates via email.
  • Contact the hosting provider's support team
    If you don't know the link to the host's status page, you can also contact the host's support team directly by phone, email, or support chat.
  • Database login
    Try accessing the database directly through your hosting control panel or, alternatively, through phpMyAdmin. Can't access the database? If so, the database server may be unavailable.
  • Go to the alternative page
    Do you have a second website hosted on the same server? If so, try accessing it. If that website also displays the error „Error establishing a database connection,“ this confirms that the database server is unavailable.

Restore the Latest Backup

I only recommend restoring a backup if the cause is still unknown to you and you have no other approach to a solution. The following tips and notes for restoring the backup:

  • Create a backup before you restore your old backup:
    With changes this large, you should always get a complete Create a WordPress Backup.
  • Start with the most recent backup:
    If you're unsure when the error on your website started, start with the most recent backup. If the error persists after that, restore the next oldest backup.
  • Data loss:
    When you restore the backup, you'll overwrite any changes that have been made since then. This can be a major problem, especially for online stores.
  • Restore database backup:
    Depending on the backup, you may be able to restore just your database. Start there, as that alone may solve your problem.

Conclusion on the "Error establishing a database connection" error„

The error „Error establishing a database connection“ is rare. There are several possible causes for this error:

  • Incorrect database information in wp-config.php
  • Deleted Database
  • Damaged Database
  • Database server is unavailable

The most common cause is incorrect database information in the wp-config.php. Therefore, I recommend checking this information first. If that does not help, you can try repairing the database or contact your host for assistance.

Pro Tip for WPspace Customers💙: Is your website showing an error? If so, contact our support chat so we can help you fix the problem! Our technical team will be happy to investigate possible causes and provide you with helpful tips.

If you're stuck, you can restore a backup of your website. Keep in mind that this may result in data loss! So be sure to create another backup before doing so.

Isabell Bergmann

As an Online Marketing Manager at WPspace, I enjoy sharing my knowledge about online marketing, web design, and hosting.

Show more by Isabell

Related posts

WordPress Performance Checkliste: In 15 Schritten zur blitzschnellen Website

July 22

David Broll

WordPress Performance Checklist: 15 Steps to a Blazing Fast Website

A slow website costs you cold hard cash: visitors bounce before the page has even finished loading, Google lowers your ranking and your...

wp_options bereinigen: Entferne Datenmüll für schnellere Ladezeiten

Clean up wp_options: Remove clutter for faster load times

Imagine you run a successful online store or a popular blog. A potential customer clicks the „Add to Cart“ button, full of anticipation...

WP Umbrella Erfahrungsbericht: Einfache WordPress-Verwaltung (2026)

WP Umbrella Review: Easy WordPress Management (2026)

Do you manage, maintain, and care for multiple WordPress websites? Then you surely know the problem of always keeping all credentials backed up centrally. In this case, [...] can help you...

Leave a Comment