WordPress

WordPress Database Connection Error

It says "Error establishing a database connection". Here’s how to check the wp-config details, database privileges and cPanel MySQL settings.

"Error establishing a database connection" means WordPress scripts loaded fine but couldn't reach their MySQL database. It's a configuration mismatch more often than an outage. Here's how to pin it down.

1. Check the credentials in wp-config.php

WordPress stores its database details in public_html/wp-config.php: DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. Open it in File Manager and compare:

ItemWhat to verify
DB_NAMEMust exactly match a database in cPanel (names often have a prefix like user_wp)
DB_USERMust match a MySQL user that has been granted access to that database
DB_PASSWORDMust match the MySQL user's password — special characters are a common spoiler after a copy/paste
DB_HOSTUsually localhost on WebFulHost shared hosting

A typo anywhere here produces exactly this error, so read it character by character.

2. Verify the user has privileges

In cPanel open MySQL Databases. Confirm your WordPress database is listed as "in use" by the wp-config username — if not, click Add User to Database, grant ALL PRIVILEGES, and the error typically clears. See How to Connect a MySQL Database to WordPress.

3. Reset the MySQL password and update wp-config

If the password has a tricky character, the cleanest path: set a fresh password for the MySQL user in MySQL Databases, then update DB_PASSWORD in wp-config.php to match exactly.

4. Could it be the server?

Rarely, the database service itself is restarted and WordPress's connection pool needs a minute to recover. Finish the other checks first; if everything matches and the error persists for more than half an hour, open a ticket — we can see server-side whether the database is accepting connections.

Just migrated the site?

After a WordPress migration, this error usually means the wp-config.php still points at the old host's database name, user or host. Re-export the database from the old host or re-point wp-config at the fresh database you created here.

Was this article helpful?

Your feedback helps us improve our guides.

Still need a hand?

Contact WebFulHost Support — our team is available 24/7.