The warning “Error establishing a database connection” means WordPress cannot reach the MySQL or MariaDB database needed to generate the page. English installations display the same “Error establishing a database connection” message, and when this WordPress database error occurs, visitors see only a one-line error page. Although posts, pages, and settings appear lost, data usually remains intact; the connection is what has broken.

This guide covers the error’s meaning, common causes, checks in the hosting panel, WordPress’s built-in repair tool, and the special case after migration, in order, based on official WordPress administration documentation. Because some steps change files and the database, backing up the current state before starting is recommended.

Error establishing a database connection: a 62-second video walkthrough
Video transcript

What does error establishing a database connection mean? WordPress cannot reach the database; although posts seem lost, data usually remains intact, and the connection is what has broken. The most common cause is incorrect wp-config information. Server load, damaged tables, settings forgotten after migration, and compromise also cause this error. First check whether it also appears in the administration panel. Then check hosting status and compare wp-config values with the panel; if tables are the issue, enable the repair tool. Database name, user, password, and host must exactly match the panel. Forgetting the account prefix breaks the connection; the host usually remains localhost. Remove the repair line afterward, or the page remains public. Do not edit files without backups or share passwords; also back up the faulty state before restoring. The post-migration checklist and information for hosting support are on the page. You can write on WhatsApp if you get stuck. Onur Freelance dot com.

If the site will not open, let us find the source first

Rushing to delete files or remove plugins when the error appears can worsen the problem. We first clarify which layer is responsible, then back up before intervening. Where possible, a separate access user is created; primary passwords are not requested through messages.

What does error establishing a database connection mean?

This message says WordPress tried and failed to connect to the database server using wp-config.php details. Because WordPress stores almost all content in the database, no pages can be generated without a connection.

According to the explanation of the dead_db() function in WordPress developer documentation, a failed connection shows a general frontend message, while more detailed database errors may appear in the dashboard and during installation. If wp-content contains a file named db-error.php, WordPress loads this custom page instead of the standard message. This file often explains why the error has a different design on some sites.

  • What it shows: The connection between WordPress and the database could not be established.
  • What it does not show: That data was deleted; in most cases, tables remain on the server.
  • Its relevance to visitors: The issue is with the server and settings, not their browser or internet connection.
  • What it cannot say alone: Which detail is wrong; step-by-step diagnosis is needed.

The most common causes of WordPress database errors

WordPress’s common errors documentation groups causes into three main areas: incorrect wp-config.php details, hosting problems, and compromised sites. In practice, damaged tables and settings forgotten during migration also occur.

Incorrect database details in wp-config.php

According to the documentation, this is the most common cause. If DB_NAME (database name), DB_USER (user), DB_PASSWORD (password), or DB_HOST (server address) differs from the actual hosting panel value, the connection is refused. The same happens when a database password is changed in the panel but not updated in the file.

MySQL server offline or overloaded

The document lists database quota exhaustion leading to shutdown and server downtime among possible hosting causes. Sudden traffic spikes or shared-server load can also leave connections unanswered; this becomes more likely if the error comes and goes during the day.

Damaged database tables

Even with a connection, WordPress cannot work if tables are unreadable. An abrupt shutdown, disk problem, or interrupted operation can damage tables; the dashboard then displays a notice suggesting repair.

Hosting changes and migration

When moving a site to a new server, the database name, user, or host may change. If wp-config.php retains old details, the site cannot connect on the new server.

Attacks or unauthorized file changes

The official document also lists compromise as a cause. Changes to wp-config.php when nobody touched it, unfamiliar files, or administrator accounts may indicate an attack. Fixing connection details alone is insufficient; passwords must be changed and the vulnerability closed, or the site may return to the same state. Cleanup and security steps fall within the hacked WordPress site recovery service.

Does the error appear only on the site or in the dashboard too?

The first diagnostic step is checking whether the same error appears at /wp-admin/; this single observation splits the possibilities. If the dashboard shows the same or a more detailed connection error, the problem most likely concerns credentials or the database server.

If the dashboard says one or more database tables are unavailable and the database may need repair, the situation differs. The is_blog_installed() function in WordPress source displays this message and links to the repair page when tables exist but the settings table is inaccessible. This means the connection works but tables have problems; WordPress’s repair tool is relevant here.

If the error comes and goes and no details have changed recently, server load becomes the leading possibility. Changing wp-config.php without making this distinction risks breaking a working setting.

Page contents

Veritabanı bağlantısı kurulurken hata oluştu: veritabanı ile sunucu arasındaki kopmuş kablo, uyarı işareti ve yapılandırma dosyasını gösteren illüstrasyon

Is there a hosting problem? Check the status page and panel

When error establishing a database connection appears, check the host’s status page and panel announcements before touching configuration; for scheduled maintenance or a database server outage, wait and open a support ticket. If other sites in the same hosting account have the same error, the problem is on the server rather than in one site’s settings.

Checks you can perform in a few minutes in the panel:

  • Any active outage or maintenance announcement on the status page or panel
  • Whether a database tool such as phpMyAdmin opens and lists tables
  • Disk and database quota usage
  • CPU, memory, or concurrent process limits being reached in resource usage charts

If phpMyAdmin opens and lists tables, the database server is running; attention shifts to credentials. For sites frequently hitting resource limits, server choice’s effect on speed and search visibility is separately explained in the web hosting selection guide.

How do you check wp-config database settings?

Check wp-config database settings by comparing four values in the site’s root wp-config.php character by character with database details in the hosting panel. Access the file through the panel file manager or FTP; WordPress documentation also recommends opening it through FTP and verifying these details as the first step.

ConstantMeaningEquivalent in the hosting panel
DB_NAMEDatabase nameThe full name in the databases list, including any account prefix
DB_USERDatabase userThe username authorized for that database
DB_PASSWORDThe user’s passwordUsually not displayed in the panel; reset if needed
DB_HOSTDatabase server addressUsually localhost; the host may provide another address or port

According to WordPress’s wp-config.php documentation, DB_HOST remains the default localhost in most installations and probably does not need changing. For servers using another port, append it to the address, for example localhost:3307. Many panels prefix database and user names with the account name; leaving the prefix out breaks the connection.

If the password cannot be viewed, reset the user’s password in the panel and put the same value in wp-config.php. Also verify on that screen that the user has the necessary permissions for the database. Copy the file before saving changes; a missing quote or semicolon can leave the site entirely blank.

Do not share the database password

wp-config.php contains the database password in plain text. Do not send screenshots to forums, social media groups, or messaging apps; conceal the password line when requesting help. If support needs access, create a temporary user instead of sharing the main password, then delete that user and change the database password afterward.

How do you repair the database with WP_ALLOW_REPAIR?

For suspected damaged tables, enable WordPress’s built-in repair tool by adding define( 'WP_ALLOW_REPAIR', true ); to wp-config.php, then use it at /wp-admin/maint/repair.php on the site. It offers table repair and optional optimization.

  1. Back up the current files and database.
  2. Open wp-config.php and add the line before the comment meaning “stop editing here”.
  3. Open alanadi.com/wp-admin/maint/repair.php in the browser.
  4. Start repair and check the table list on the results screen.
  5. Immediately remove the added line from wp-config.php, then test the site and dashboard.

Do not skip the final step. According to WordPress’s editing wp-config documentation, enabling this setting allows access to the repair page without login because login may be impossible with a broken database. The document recommends enabling it only when needed and disabling it after resolution; forgetting the line leaves the page publicly accessible.

The repair tool does not fix connection problems caused by incorrect usernames or passwords; it addresses only table issues. Without a dashboard repair warning, this step does not advance diagnosis.

When and how should you contact hosting support?

If panel details exactly match wp-config.php, phpMyAdmin will not open, or resource limits are exhausted, the solution lies with hosting support; restarting the database server or increasing quota is beyond the owner’s control. A clearer support ticket gets a faster response. Include:

  • The domain and time the error first appeared
  • Whether the error appears on the frontend, in the dashboard, or both
  • Recent changes: updates, migration, password changes
  • The status of other sites in the same account
  • Whether phpMyAdmin opens

Do not put passwords in support tickets; use the host’s own panel and official support channel for authentication. If someone asks for the database password by phone or email, separately confirm the request comes through the company’s official channel.

When is restoring a backup the last resort?

If details are correct, the server works, and repair fails, or tables are severely damaged, restoring the last good backup is the safest solution for error establishing a database connection. Because restoring loses content and orders added afterward, first check the latest backup’s date and coverage.

WordPress’s backup documentation states that both files and the database are needed for full restoration. According to it, restore files first, then import the database and update configuration if necessary. If the host provides automatic backups, restoration can often be started in the panel.

Also back up the faulty state before restoring. If the restored backup turns out to have the wrong date, this copy may be the only source for recovering lost content.

Repair or restore? Let us decide using data

Restoring in the wrong order can delete recoverable content too. We examine the source, latest backup date, and hosting status together, and intervene after backing up the current state. Scope and timing are clarified in the initial consultation.

Database connection errors after migration

Error establishing a database connection after moving to new hosting most often results from wp-config.php retaining old server details. WordPress’s migration documentation states that wp-config.php must be updated if the database name or user changes.

The post-migration checking order is:

  • Was the database created on the new server and the backup imported?
  • Was the new user authorized for this database?
  • Do the four wp-config.php values match the new panel?
  • Is DB_HOST localhost on the new host, or a separate address supplied by the company?
  • If the domain still points to the old server and its database was deleted, could the error be coming from there?

The same document notes that using the same database name and creating a user with the same credentials on the new server simplifies matters. If migration is planned, these checks are performed beforehand as part of the WordPress site migration process.

Independent intervention or specialist support?

Checking hosting status and comparing wp-config details with the panel are tasks owners can handle; specialist support reduces risk when file editing, repair, restoration, or suspected attacks enter the picture. Online quick-fix lists often suggest trying every step at once, while controlled diagnosis first identifies the responsible layer.

CriterionRandom attemptsControlled diagnosis
Starting pointFile editing, plugin deletionDistinguishing frontend, dashboard, and hosting
BackupOften skippedTaken before every intervention
Repair toolEnabled and potentially forgottenEnabled only when needed and disabled afterward
PasswordsMay be shared by messageTemporary access and a password change afterward
RecordsWhat changed remains unclearEvery step is noted

Specialist support makes sense for error establishing a database connection when it persists after repair, there are signs of attack, the latest backup is old or absent, migration is incomplete, or the error recurs frequently. For sites gaining customers through orders, appointments, or forms, longer downtime means direct business loss.

At Onur Freelance, we follow this order for WordPress problems: first back up the current state, narrow the error layer by layer, and share changes with the owner. One-time faults are handled through the WordPress troubleshooting service. Onur Freelance is not an official support channel for WordPress or hosting companies; only the hosting company can fix server infrastructure faults.

Preventing WordPress database errors: maintenance, backups, and resource monitoring

There is no single way to completely prevent error establishing a database connection; three habits reducing risk are regular maintenance, tested backups, and resource monitoring. WordPress’s backup documentation recommends weekly backups for infrequently updated sites and daily backups for frequently updated sites, keeping at least 3–5 current backups across locations such as server, cloud, and local computer.

  • Update core, themes, and plugins after backing up
  • Occasionally test whether automatic backups can actually be restored
  • Regularly monitor disk, database quota, and resource usage
  • Remove unused plugins and themes
  • Keep hosting, FTP, and database passwords strong and never share them

For sites frequently reaching resource limits, a more suitable hosting plan may be part of a lasting solution. At Onur Freelance, hosting costs 2,000 TL annually and is opened in the business’s name; details appear on the hosting prices page. WordPress maintenance is planned at 500–2,000 TL per month depending on site size and scope.

Regular maintenance to avoid the same error again

If this is the first occurrence, the sequence above reveals the source in most cases. If you are deciding what to do, the existing backup setup and hosting status are reviewed in a free preliminary assessment. For ongoing updates, backups, and resource monitoring through the annual WordPress maintenance and updates service, get in touch by WhatsApp or phone.

Frequently asked questions

It means WordPress cannot connect to the database server using wp-config.php details. Data usually remains intact; the issue concerns credentials, the server, or tables.

No; the error only shows a failed connection, not deleted data. If tables are severely damaged, data loss is a separate matter and restoring a backup may be necessary.

DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST appear in wp-config.php in the site’s root directory. Compare these values with the database section in the hosting panel.

According to WordPress documentation, localhost stays unchanged in most installations. If hosting uses a different server or port, enter the supplied address, appending the port if needed.

With this setting enabled, the repair page is accessible without login. WordPress documentation recommends enabling it only when needed and disabling it once the problem is resolved.

The most common reason is wp-config.php retaining the old server’s database name, user, or password. Also check that the new database was created, the backup imported, and the user authorized.

No; do not share it through messages, forums, or screenshots. If access is required, create a temporary user, delete that user afterward, and change the password.

At Onur Freelance, WordPress maintenance is planned at 500–2,000 TL per month depending on site size and scope. Onur Freelance is not an official support channel for WordPress or hosting companies.