The message ‚Error establishing a database connection‘ means WordPress cannot connect to the database where all your content is stored. This is usually caused by incorrect login details in wp-config.php, a corrupted database, or a problem with the database server itself. In this article, we’ll walk you through step by step what’s wrong and how to fix it.
What exactly does this error message mean
WordPress stores almost all content (posts, pages, settings) in a MySQL or MariaDB database. For every page visitors open, WordPress retrieves data from that database via the file wp-config.php. If that connection fails, WordPress shows this generic error message instead of your website. The cause can lie with WordPress itself, but also with the database or the server it runs on.
The connection route between WordPress and the database.
Finding the cause step by step
Check wp-config.php
Open the file via FTP or the file manager in Plesk and check whether DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST are correct. A typo or a changed password is the most common cause.
Test the database details
Log in to database management in Plesk and check whether the database user still exists and whether the database name is correct. Sometimes a user is accidentally deleted or changed.
Check if the database is running
Check whether the database server itself is reachable. If this is the case for multiple websites on the same server, the problem is probably not with your WordPress installation but with the server.
Check for corrupted tables
A sudden power outage, incorrect migration, or full disk space can corrupt tables. This is often recognizable by separate error messages about specific tables rather than a general connection error.
Restoring or repairing the database
If the tables are corrupted, you can use WordPress’s built-in repair function. Temporarily add this line to wp-config.php: define('WP_ALLOW_REPAIR', true); and then visit yoursite.com/wp-admin/maint/repair.php. Follow the buttons to have tables checked and repaired. Remove the line from wp-config.php afterwards, as anyone with the link could otherwise access this page.
If repair doesn’t work, falling back on a recent backup is often the fastest solution. In Plesk, you can easily restore an earlier version of both files and database. At Tandata, this relies on daily backups, so you never have to go back far.
Preventing it from happening again
Make sure wp-config.php only changes through a deliberate action, keep passwords in a secure place, and always check immediately after a server move or migration whether the site loads properly. Also use a stable hosting environment with sufficient disk space, as a full disk is an underestimated cause of database problems. If you’re unsure whether your current hosting is suitable for this, check out the options for web hosting with NVMe storage and daily backups.
If you’re considering switching to another provider due to recurring problems, first read how switching to Tandata works, so your site moves without hassle.
Frequently Asked Questions
Is all my content lost with this error message?
No, usually not. The error message only means WordPress cannot reach the database, not that the data is lost. Once the connection is restored, your content is typically visible again as usual.
Can I fix this myself without technical knowledge?
The first steps (checking wp-config.php and login details) can often be done yourself via Plesk. For corrupted tables or server problems, it’s wise to get help through the knowledge base or support.
How do I know if the problem is with WordPress or the server?
If other websites on the same server also have database problems, the issue is probably with the server. If only your site isn’t working, the problem is usually in wp-config.php or the database itself.
Conclusion
A database error message in WordPress can almost always be resolved by first checking the details in wp-config.php, then testing the database and user, and finally repairing the tables or restoring a backup. With a stable hosting environment and daily backups, you prevent these kinds of problems from persisting for long.