Knowledge Base
How do I fix “Error establishing a database connection” in WordPress?
“Error establishing a database connection” means WordPress cannot connect to the database it needs. Check when the problem began and any recent website move, password or configuration change. In cPanel → Manage My Databases, confirm the existing database and its assigned user. Do not reinstall WordPress, create an empty replacement database or reset passwords blindly. A server problem can produce the same message, so ask us to check the hosting when the cause is unclear.
Record the problem before changing anything
- Note the exact website URL, time with timezone, error and last time it worked. Check whether both the public website and
/wp-admin/fail, and whether the problem started after a migration, restore, password change or developer update. - If several websites on the same hosting account fail together, tell us. That can help us check the database service, but does not by itself prove a server outage.
- Protect the existing website files and database using our backup guide before any repair. If the database cannot be backed up or the account is full, stop and ask us to check it rather than starting a restore over the current site.
Identify the site's existing database
- Sign in to your account, choose Services, find the correct hosting service and choose Log in to cPanel. On a phone, choose cPanel.
- Open Domains and find the affected domain. Check its Document Root and open that folder's link in File Manager. For WordPress in a subfolder, open the correct installation folder before continuing.
- Ask your website maintainer to inspect that installation's
wp-config.phpprivately. The settings DB_NAME, DB_USER, DB_PASSWORD and DB_HOST identify the connection. The configuration can also load values from another private source, so do not assume every installation stores them in the same form. - Do not paste this file, its database password or its security keys into a ticket or chat. The database password is separate from your WordPress administrator, cPanel, mailbox and account passwords.
Check the database and assigned user
- In cPanel Tools, open Manage My Databases. Under Current Databases, find the full database name identified for the affected site, including the account prefix. Check that the expected username appears under Privileged Users for that database.
- Choose that existing Privileged Users username link to open Manage User Privileges. Check the displayed User and Database without changing them. Use Go Back to leave. A listed user does not prove the saved password is correct or that the database service is healthy.
- If the database or user is missing after a move or restore, stop and have your maintainer compare the migration or backup records. Creating a new empty database with a similar name will not restore the website's content. See database setup for the distinction between a database, its user and their access.
- If the names and assignment match, ask the maintainer or us to confirm the correct database server address and credentials. Do not guess DB_HOST, replace it with the website domain or reset a shared database user to test a theory. A password change can break other sites using that user.
Make only the repair the evidence supports
- Have the maintainer correct a confirmed configuration mismatch or restore the intended user's access to the intended database, keeping a backup and a way to undo the change. Our database guide shows the user-assignment controls; it is not a reason to create a replacement for this incident.
- If credentials and permissions are correct, ask us to check the database service, storage and account restrictions. Browser cache changes and repeated WordPress installations will not repair a failed database connection.
- Do not enable a public WordPress database-repair page or run a repair across every database just because this error appears. Repair is a separate operation for a diagnosed table problem and needs an appropriate backup.
- After a targeted fix, check the home page, important content and WordPress sign-in. For a shop or booking site, confirm the expected recent data with your maintainer. Do not place a real order or restore older data merely to test the connection.
Give us the evidence securely
- Open Support → New Ticket, set Department to Tech/Server, choose Priority and enter Subject and Message with the domain, exact error, time, recent changes and the existing database/user names, then choose Open ticket. Tell us whether other sites on the account are affected and whether the database and user are listed. Keep credentials and full configuration files out of the ticket.
