Fix It Yourself

“Error Establishing a Database Connection” Explained in Plain English

Your website has two halves: the files (code, images, design) and the database (every post, page, order and setting). This error means the files are fine but WordPress can’t reach the database. The site can’t function without it — so visitors get this message instead.

Why it happens

  • The database server is down — the most common cause on shared hosting, and it’s your host’s problem.
  • Wrong credentials — something changed the database name, username, password or host address that WordPress uses to connect.
  • A corrupted database — often after a failed update or the server running out of disk space.
  • Traffic overload — a spike (or a bot flood) exhausts the database’s connections.

Step 1: Is it just you?

Check the site from another device. Then check your hosting provider’s status page — if the database server is down, your only job is waiting (and maybe considering a better host).

Step 2: Check the credentials

Open wp-config.php via your host’s file manager and note the four values: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST. Compare them against the database section of your hosting panel. If they don’t match — that’s your fix.

Step 3: Try the built-in repair tool

Add this line to wp-config.php: define( 'WP_ALLOW_REPAIR', true ); — then visit yoursite.co.za/wp-admin/maint/repair.php and click repair. Remove the line afterwards; that page is public while enabled.

Step 4: Call the host

If none of that works, your host can see server logs you can’t. Ask specifically: “Is the MySQL server up, and is my database intact?”

The lesson

Database errors are the strongest argument for off-site backups — a backup stored on the same server dies with the server. Every WP Hero plan stores backups independently of your hosting.

Rather have a hero handle it?

WP Hero keeps your WordPress site updated, backed up and monitored — with unlimited small fixes included. Flat fee, no hourly billing, from R499/month.

See plans How it works

Keep reading