Fix "Error establishing a database connection"

database error, wordpress, wp-config, credentials, repair, troubleshooting · 0 found this helpful

This message means WordPress can't talk to its database. Common causes are wrong details in wp-config.php, a changed password, a damaged table, or a site that has hit a resource limit.

1. Check the details in wp-config.php

Open wp-config.php in the file manager in Files and find:

define( 'DB_NAME',     'yourusername_bakery' );
define( 'DB_USER',     'yourusername_shop' );
define( 'DB_PASSWORD', '...' );
define( 'DB_HOST',     'localhost' );

Compare with Account → Hosting → your site → Databases.

  • Is the database name exactly right, including the prefix?
  • Is the user listed under Users, with access to that database under Database privileges by user?
  • Is the password right? If unsure, set a new password in Databases and update the file.
  • DB_HOST should be localhost.

2. Test the login

mysql -u yourusername_shop -p yourusername_bakery -e "SELECT 1;"

An Access denied error means credentials or privileges are wrong. Re-add the user to the database with ALL PRIVILEGES.

3. Check and repair tables

Corrupt tables can also cause the error. Add this to wp-config.php temporarily:

define( 'WP_ALLOW_REPAIR', true );

Then visit https://example.ca/wp-admin/maint/repair.php. Remove the line after. Or follow Check and repair a database.

4. Check resources

If the error comes and goes, the site may be hitting limits for CPU, memory, or processes. Look at Account → Hosting → your site → Performance. See Resource limits explained. Bots and heavy plugins are common causes. Block bad traffic. See Block visitors by IP.

5. Check disk space

A full account can't write to the database. See See what's using your storage and Inodes.

6. Restore

If nothing works and the site worked yesterday, restore the database from a daily backup. See Back up and restore WordPress.

Which message is it?

Where Meaning
Front page only Database fine, front page failing. Check plugins
wp-admin says "One or more database tables are unavailable" Repair
Front and admin Credentials or server

Still failing?

Contact [email protected] with the time it started and what you changed.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.