How to Fix a Database Connection Error
"Error establishing a database connection" looks scary but has a short list of causes — almost always credentials. Work down this list.
Step-by-step
- Find the credentials your site is using. Open the application's config file in File Manager (e.g. a config or settings PHP file) and note the database name, user, password and host it expects.
- Check the host is "localhost". On EconomicalHost cPanel hosting the database host is localhost — not an IP or remote hostname.
- Verify the database and user exist. Databases → Manage My Databases: confirm the exact names including the youruser_ prefix — a missing prefix in the config is the most common typo.
- Confirm the user is attached to the database with ALL PRIVILEGES. The "Add User To Database" section shows current pairings; re-add with all privileges if absent.
- Reset the database user's password (MySQL Databases → Current Users → Change Password) and put the same new password in the config file. This rules out a silent mismatch.
- Check for corrupted tables: Manage My Databases → Check Database; use Repair Database if errors are reported.
- Still down? Note the exact moment it broke and contact EconomicalHost support — we can check the database server status and logs.
💡 Good to know
- If the site worked yesterday and nothing changed, suspect a password change or a migration left old credentials behind.
- Never edit the config file without a copy of the original saved first.
- Repeated intermittent errors under traffic can mean the app exceeds connection limits — caching plugins reduce database load dramatically.