How to Fix “Error Establishing a Database Connection”
WordPress can't connect to its database. Check that the database name and username in wp-config.php match the Databases section of cPanel, ask us to check the database login if they do, and check the status page.
Applies to: cPanel WordPress Blue Arctic Shared Web Hosting (cPanel); WordPress 7.x
On this page
WordPress keeps your posts, pages and settings in a database. This message means WordPress couldn’t log in to it, so nothing can load. The usual causes are a changed password, a wrong detail after a move, or the database service being briefly unavailable.
Note
These steps use cPanel on Shared Web Hosting. If you have Managed WordPress Hosting, open a support ticket instead. If you can’t find a cPanel tool named below, type its name in cPanel’s search box (Ctrl+K or Cmd+K). If you can’t log in to cPanel or still can’t find it, open a support ticket.
Step 1: Check whether it’s a wider problem
- Open the Blue Arctic status page. If it shows an incident, wait for the update.
- If you have more than one WordPress site, check whether they all show the error. If they all do, open a support ticket.
Step 2: Compare wp-config.php with cPanel
- Log in to cPanel, click Files in the sidebar and open the File Manager tab. If you see a File Manager icon instead, click it.
- Open
public_html(or the folder for this site). - Select
wp-config.php, click More and choose Edit. Don’t change anything. - Find the lines for
DB_NAME,DB_USERandDB_HOST. Each value is in the second pair of quotes. For example, indefine( 'DB_NAME', 'example_wp123' );the database name isexample_wp123. - In cPanel, click Databases in the sidebar and check that a database with exactly the
DB_NAMEname is listed. - Click Manage next to it, open the Users tab and check that the
DB_USERname is listed.
If you see a Manage My Databases icon instead, click it and check under Current Databases that DB_USER is listed under Privileged Users for that database.
Names must match letter for letter, exactly as cPanel shows them.
If the user isn’t listed for that database, or the database or user isn’t in cPanel at all, don’t add or create anything. Open a support ticket with both names (never the password).
Leave DB_HOST as it is. If you moved the site from another host and DB_HOST isn’t localhost, open a support ticket before changing it.
Step 3: Ask us to check the database login
If the names match, the password is the most likely cause.
- Open a support ticket and ask us to check the database login for your site. Include your site address and the
DB_NAMEandDB_USERnames. Never put a password in the ticket. - If other applications use this database user, mention them.
Step 4: If the message changes to “tables are unavailable”
If WordPress says “One or more database tables are unavailable. The database may need to be repaired.”, a table may be damaged. Don’t try to repair it yourself: a repair can lose data in rare cases. Open a support ticket with the exact message and ask us to check the database. We keep daily backups for 30 days.
How to tell it worked
Your site and its admin area load normally in a private browser window.
Troubleshooting
- The error started with no change on your side: check the status page, then open a support ticket. Someone may also have changed the password. If you suspect a break-in, say so in the ticket right away.
- After moving the site: if we moved it for you, open a support ticket and we’ll look at it. If you moved it yourself, the database name and user usually change; repeat Step 2 with the new account’s details.
- The database is missing from the list: don’t create a new empty one. Open a support ticket and ask about restoring it from a backup.
Still need help?
Open a support ticket from the Client Portal at my.bluearctic.com. Include your site address, when the error started, whether you changed anything, the database name (never its password), and what you already tried. Never include a password.