The “Error establishing a database connection” message means WordPress cannot connect to its database. WordPress needs both website files and a MySQL database to load. If the database connection fails, the site cannot display normally.
Common causes
- Incorrect database name, username or password in wp-config.php.
- The database user does not have the correct permissions.
- The MySQL service is unavailable.
- The database has been deleted or corrupted.
- The hosting account has been moved and configuration is outdated.
- The site has exceeded resource limits.
What to check
- Open wp-config.php and check DB_NAME, DB_USER, DB_PASSWORD and DB_HOST.
- Check that the database exists in cPanel.
- Check that the database user is assigned to the database.
- Check whether phpMyAdmin can access the database.
- Review any recent migration or restore work.
When this happens after migration
This error is common when WordPress files are moved but the database or database user was not restored correctly. A proper migration should include files, database, configuration and DNS testing.
Need help?
Open a support ticket directly from within your GetHosting.online customer account. Phone support is also welcome on (+44) 01457 337 247. For international contact numbers, please see our contact page.
GETHOSTING.ONLINE is a subsidiary of GetUK Support.