“Error establishing a database connection” means WordPress cannot reach its database. It is a common error with a few clear causes. This guide explains how to diagnose and fix it.
What the error means #
WordPress stores your content in a MySQL database. If it cannot connect, usually because of wrong credentials, a database issue, or a server hiccup, it shows this error instead of your site.
Step 1: Check your database credentials #
Abrir wp-config.php and confirm the database name, username, password, and host (usually localhost) match what is in your hosting control panel. A recent migration or password change is the most common cause of a mismatch.
Step 2: Confirm the database user’s access #
- In your control panel, make sure the database user is assigned to the database.
- Confirm the user has the right privileges.
Step 3: Check the database itself #
Open phpMyAdmin and confirm the database exists and has tables. Occasionally a database can need repair, which WordPress can attempt if you enable repair mode.
Step 4: Rule out a server issue #
If credentials are correct and it still fails, the database server may be temporarily overloaded or down. Wait a few minutes and retry, and check whether other sites on the account are affected.
Troubleshooting summary #
- After a migration: fix the credentials in wp-config.php.
- Suddenly, no changes: likely a temporary server issue; retry shortly.
- Corrupt database: try WordPress repair mode.
Precisa de ajuda? #
If the error persists, our support team can check the database and server for you over live chat.