When WordPress displays “Error establishing a database connection,” your website may stop loading even though you can still open your hosting dashboard. The timing is your first clue. If the error appeared immediately after a migration, verify the database settings on the new host. If it appeared across several sites on the same server, check for a hosting incident before editing any files.
Here’s how to diagnose the WordPress database connection error, starting with checks that require no changes. You’ll learn what to compare in wp-config.php, what to ask your host, and when a database repair makes sense.
What does the WordPress database connection error mean?
WordPress needs to reach its database to load content and settings. The message tells you the connection failed. The cause could be an unavailable database service, incorrect login details, or a hosting limit. Check the evidence before choosing a fix. WordPress Advanced Administration Handbook
| What you notice | What to check first |
|---|---|
| The error began after a migration or restore | Database host, name, user, and the user’s access to the imported database |
| The error began after a password change | Whether WordPress uses the current database password |
| Several sites sharing the database server fail together | Database service status, resource limits, or a hosting incident |
| The site works again after a refresh | Database logs, restarts, and connection limits around the time of failure |
| A database check identifies a damaged table | Backup availability and a repair method supported by the host |
1. Confirm where and when the error appears
Open the homepage and the WordPress admin login page, usually at /wp-admin/. Check a second public page too. If a public page loads but the admin page fails, a cache may be serving the public page. Ask your host how to verify a request reaches the live WordPress installation if you are unsure.
Record the affected URLs, the time and time zone, and whether the error comes and goes. Note any recent migration, database password change, restore, or hosting maintenance. For an intermittent problem, timestamps are especially helpful because support can compare them with server logs.
2. Check the database service with your host
Look at your host’s status page and hosting dashboard for an incident affecting your server or region. A green public status page can coexist with an issue on your specific account. Ask support whether the web server can reach the database server and whether your account hit a connection, storage, or resource limit.
If your host provides phpMyAdmin, check whether you can open the expected database. A working phpMyAdmin session confirms access through that session. Your hosting panel may sign in differently from WordPress, so verify the WordPress user and its permissions separately.
3. Compare the database settings in wp-config.php
Use your host’s file manager or SFTP to locate the active installation’s wp-config.php. On accounts with several sites, confirm that you are looking at the installation for the affected domain. Keep a private backup of the configuration before editing. The file may contain credentials and security keys.
Check these four values
| Setting | What to verify |
|---|---|
DB_NAME | The exact database name, including any hosting account prefix |
DB_USER | The database username assigned to that database |
DB_PASSWORD | The current password for that database user |
DB_HOST | The hostname or connection details supplied by your host |
Some hosting environments use values supplied through environment variables or managed configuration. If you see a reference to one, check where the value is set before editing the file. Use the database host supplied by your provider, including a port or socket where specified. WordPress documentation on wp-config.php
After a migration, check the user assignment
Imagine you copied the WordPress files and imported the database on a new host. The old database username may still be in wp-config.php. Even if you recreate that username, the host may require you to assign it to the newly imported database. Check that assignment and the configured host before resetting a password.
If you must reset a database password, first identify any other sites or applications that share the same database user. Update the affected configurations together. Keep passwords and complete configuration files out of support tickets and public screenshots.
4. Read the error behind the WordPress message
Check the PHP or database logs in your hosting dashboard. If you lack access, give support the timestamp and ask for the relevant database error. The wording can narrow the next check.
| Error clue | What it can mean |
|---|---|
| Access denied for user | The login was rejected. Verify the username, password, and whether that account can connect from the web server. |
| Unknown database | The database name may be wrong, or the expected database may be missing from the server you reached. |
| Connection refused or timed out | The database service or network path may be unavailable. Verify the host and port with your provider. |
| Too many connections | The database may have reached a connection limit. Ask support which limit was hit and what was happening at the time. |
For recurring failures, compare several timestamps with traffic spikes, backups, imports, and scheduled tasks. A timing pattern gives you something specific to investigate. Logs and resource metrics can help confirm the cause.
5. Consider repair only when a check identifies table damage
Database repair addresses certain table problems after the database is reachable. If the server rejects the login or cannot be reached, resolve that connection problem first.
When the host or a database check identifies table damage, confirm that you have a usable backup and ask which recovery method suits the affected table and storage engine. WordPress provides a built-in repair mode. If you use it, enable it only for the repair and remove the setting immediately afterward, since the repair page can be accessed without signing in while it is enabled. WordPress documentation on automatic database repair
A backup restore can replace newer orders, comments, form entries, or content. Check the restore point and plan how to preserve recent records before restoring a live database.
6. Verify the site after it reconnects
Open the homepage, an individual post, and the admin dashboard. Check that the content belongs to the intended database, especially after a migration or restore. If the site accepts orders, registrations, or submissions, test a relevant workflow using a staging environment or your normal live testing procedure.
If the failure was intermittent, monitor the site through the period when it usually occurred. Record what changed and which evidence pointed to the cause so you have a starting point if it returns.
Frequently asked questions
Does this error mean my WordPress content is gone?
The message means WordPress could not connect at that moment. Ask your host to confirm that the database exists, or check the expected tables through your hosting dashboard if you have access.
Is the WordPress database password the same as my admin password?
They serve different purposes. The database password lets the application connect to the database. Your admin password signs you into the WordPress dashboard.
Can a plugin cause a database connection error?
A plugin that runs a heavy import or background task can contribute to database load. If an outage coincided with a plugin change, use logs to check for a link before disabling features on a live site.
Why does the error disappear after I refresh?
The database service or connection may have recovered between requests. Give your host the failure timestamps and ask about restarts, resource limits, and connection counts during those windows.
Should I reinstall WordPress to fix the error?
First verify the database server, credentials, and user permissions. Replacing WordPress files is relevant if you have separate evidence of a file problem. Confirm you have a backup before replacing files.
Conclusion
Use the timing of the error to decide where to start. Check the new host’s database settings after a migration, and ask for timestamped logs when failures come and go. Once you correct the cause, confirm that WordPress loads the right database and that the workflows your visitors rely on still work.


