Question: How do I fix database connection errors in WordPress? Print

  • GHFS web hosting, GHFS Hosting, GHFS cloud hosting, shared hosting guide, VPS hosting setup, hosting knowledge base, best hosting provider, hosting control panel tutorial, domain and hosting tutorials, how to register a domain, DNS configuration guide, how to transfer a domain, managed hosting services, SSD web hosting, DNS records explained, MX record setup, A record guide, SSL installation guide, email hosting setup, WordPress migration guide, CNAME configuration, SSL certificate troubleshooting, fix internal server error, WordPress installation GHFS, optimize WordPress performance, FTP upload guide, enable SSH access, secure VPS server, Linux server commands, website security tutorial, PHP configuration guide, MySQL database tutorial, malware removal guide, DDoS protection GHFS, secure hosting best practices, VPS hosting tutorial, cloud server configuration, how to manage Linux VPS, Nginx setup GHFS, disable root login SSH, Apache configuration guide, firewall configuration VPS, install Docker on VPS, Python hosting tutorial, Node.js on VPS, MySQL optimization, SSL troubleshooting, hosting performance optimization, hosting troubleshooting guide, secure website setup, Plesk tutorial, cPanel tutorial, Redis installation, server hardening tutorial, email deliverability guide, SMTP configuration guide
  • 0

Answer : 

A “Error establishing a database connection” message in WordPress means that your website cannot communicate with its MySQL database. This issue can be caused by incorrect credentials, corrupted database tables, server problems, or changes made during migration.

This guide explains the most common causes and how to fix them on GHFS Hosting.


1. Check Database Credentials in wp-config.php (Most Common Fix)

Incorrect database information prevents WordPress from connecting.

In your hosting account:

  1. Open Plesk

  2. Go to File Manager

  3. Open your WordPress folder (usually /httpdocs/)

  4. Edit wp-config.php

Verify the following lines:

 
 
define( 'DB_NAME', 'yourdbname' ); define( 'DB_USER', 'yourdbuser' ); define( 'DB_PASSWORD', 'yourdbpassword' ); define( 'DB_HOST', 'localhost' );

Make sure:

  • DB_NAME matches the correct database

  • DB_USER matches the assigned MySQL user

  • DB_PASSWORD is correct

  • DB_HOST is usually localhost in GHFS Hosting


2. Check Your Database Credentials in Plesk

To confirm the correct values:

  1. Go to Databases

  2. Select your database

  3. Open User Management

  4. Confirm the database username and password

If needed, you can reset the password and update it in wp-config.php.


3. Check if the Database Server is Running

In rare cases, the MySQL server may be temporarily overloaded.

Signs:

  • phpMyAdmin also fails to load

  • Other sites on the same hosting have issues

Solution:

  • Wait a few minutes

  • Try again

  • If issue continues, contact GHFS Hosting support


4. Repair WordPress Database (If Tables Are Corrupted)

Sometimes tables become broken, especially on WooCommerce sites.

Enable WordPress Repair Mode:

  1. Edit wp-config.php

  2. Add this line:

 
 
define( 'WP_ALLOW_REPAIR', true );
  1. Go to:

 
 
https://yourdomain.com/wp-admin/maint/repair.php
  1. Click Repair Database

After completion, remove the repair line for security.


5. Fix a Corrupted .htaccess File

Bad rules in .htaccess may block database access.

Regenerate .htaccess:

  1. Rename .htaccess to .htaccess-old

  2. Log in to WordPress admin

  3. Go to Settings → Permalinks

  4. Click Save to generate a fresh .htaccess


6. Fix Database Overload (High Traffic / Large Site)

If your site has:

  • Heavy traffic

  • Many plugins

  • WooCommerce store

  • Bots scanning your site

The database may become overloaded.

Solutions:

  • Enable caching (LiteSpeed Cache, WP Super Cache, WP Rocket)

  • Optimize your database

  • Limit Heartbeat API

  • Use Cloudflare to reduce load

  • Upgrade to a higher hosting plan or VPS


7. Restore Database from a Backup (If Corruption Is Too Severe)

If tables are severely damaged:

  1. Go to Plesk → Websites & Domains

  2. Click Backup Manager

  3. Choose a backup containing the working database

  4. Restore only the database section

This can quickly restore your site.


8. If WordPress Was Recently Migrated

Migration often causes database connection errors due to:

  • Wrong DB name

  • Wrong DB username

  • Wrong password

  • Wrong DB hostname

Double-check everything in wp-config.php.

If you imported the database manually, ensure the import succeeded without errors.


9. When to Contact GHFS Hosting Support

Contact support if:

  • Your credentials are correct but the error still appears

  • phpMyAdmin does not open

  • Database tables appear missing

  • Import or restore fails

  • You believe the database server is down

  • You need expert help repairing a corrupted database

Support can check logs and repair database issues for you.


Was this answer helpful?

« Back