🔍 What Causes This Error?
This error appears when your WordPress website can’t connect to the database. Your database is where all your website content, settings, and user information are stored.
The connection usually fails because of:
- Incorrect database username or password
- Moved website to a new server without updating settings
- Database server down or out of memory
- Corrupted database files
In my case, the issue started right after moving my website from an old server to a new one.
🧰 Step 1: Check With Your Hosting Provider
Sometimes, your hosting provider’s database memory might be full, or the database server could be temporarily unavailable.
Before changing anything, contact your hosting provider and ask if there’s a server-side issue. If they confirm everything is fine, proceed to the next steps.
🖥️ Step 2: Access Your cPanel
Log in to your hosting cPanel and open the File Manager. This is where all your website files are stored.
📁 Step 3: Locate the wp-config.php File
Inside your website’s root folder (usually called public_html), find the wp-config.php file.
Right-click on it and select Edit to open it in the cPanel editor.
⚙️ Step 4: Check Your Database Details
Scroll down until you see lines that look like this:
- php
- Copy code
- define(‘DB_NAME’, ‘your_database_name’);
- define(‘DB_USER’, ‘your_database_user’);
- define(‘DB_PASSWORD’, ‘your_database_password’);
- Make sure these details match your actual database name, user, and password. If the password is wrong, WordPress won’t be able to connect to your database.
🔑 Step 5: Reset Your Database Password
Go back to cPanel → MySQL Databases.
Find your database user (the same one listed in wp-config.php) and click Change Password.
You can set a new password manually or use the password generator.
After that, copy the new password and save the change.
🧾 Step 6: Update the wp-config.php File
Return to your wp-config.php editor, replace the old password with the new one, and click Save Changes.
Now your WordPress should be able to reconnect to the database successfully.
🔄 Step 7: Refresh Your Website
Go back to your browser and refresh your website.
If everything is correct, your website will load normally again — problem solved!
💡 Final Thoughts
Fixing the “Error Establishing a Database Connection” issue may sound technical, but once you understand where the problem comes from, it’s simple to resolve.
If you’ve followed all the steps and your website is still not working, don’t worry — I can help you fix it professionally.
Visit my website wppeoples.com and get in touch for expert WordPress support.





