What Is a Database Connection Error?
The "Error establishing a database connection" message means your website's application cannot communicate with its database server. This is a critical error that typically brings your entire site down since most content is stored in the database.
Common Causes
- Incorrect database credentials – The database name, username, password, or hostname in your configuration file does not match what is set up on the server.
- Database server is down – The MySQL or MariaDB service may be temporarily unavailable due to maintenance or an issue.
- Corrupted database tables – Tables can become corrupted after a server crash, sudden power loss, or a failed write operation.
- Database user privileges – The database user may not have been granted the necessary permissions on the database.
- Exceeded database connection limit – If too many simultaneous connections are open, new connections will be refused.
How to Fix It
- Verify credentials – For WordPress, open
wp-config.phpand check these values:DB_NAME– The exact database name as shown in cPanel > MySQL DatabasesDB_USER– The database usernameDB_PASSWORD– The password for that userDB_HOST– Usuallylocalhoston shared hosting
- Check user privileges – In cPanel under MySQL Databases, scroll to the bottom to confirm the user is assigned to the database with All Privileges.
- Repair the database – For WordPress, add
define('WP_ALLOW_REPAIR', true);towp-config.php, then visityourdomain.com/wp-admin/maint/repair.php. Remove the line when done. - Repair via phpMyAdmin – Open phpMyAdmin in cPanel, select all tables, and choose Repair table from the dropdown.
- Check server status – Visit the SillyHost status page or contact support to check if the database server is experiencing issues.
Database connection errors are often urgent. If the above steps do not resolve the issue, contact support immediately for assistance.