Initial assessment without passwords Quote before intervention One accountable specialist from start to finish

Errors & Diagnosis

Error Establishing a Database Connection in WordPress

This message means WordPress could not reach the database with its current settings. It rarely means data loss. Here is how to triage and fix it safely.

Short answer: WordPress could not connect to the database using the credentials and host in wp-config.php. That can be a wrong credential, a stopped database service, a connection limit or corruption — and the difference decides everything you do next. In most cases the data is intact.

Triage before touching files

  • Does it affect one site or every site on the account? Every site down points at the database server, not your config.
  • Is the host’s status page reporting an incident?
  • Was there a migration, a password change or a deployment just before?
  • Has the account hit its disk quota or its maximum connections?

Check the four values in wp-config.php

Open wp-config.php and confirm DB_NAME, DB_USER, DB_PASSWORD and DB_HOST against what your hosting panel shows. DB_HOST is the usual trap — it is localhost on many hosts but a specific server name or socket path on others. Do not overwrite the whole file with a fresh one: you would strip the table prefix, salts and environment constants. Compare values instead, and never paste the file’s contents anywhere public — it holds your database password.

Test the connection directly

If the credentials look right but it still fails, test whether the database itself responds. Log in to phpMyAdmin or your host’s database tool with the same DB_USER and DB_PASSWORD. If that login fails too, the credential or the user’s privileges are the problem. If it succeeds, the issue is in how WordPress reaches the server — often DB_HOST or a service that is down.

When a table is corrupt, not the connection

If the service responds but WordPress still errors on some pages, a table may be marked as crashed. WordPress has a built-in repair mode: add define('WP_ALLOW_REPAIR', true); to wp-config.php, visit /wp-admin/maint/repair.php, run the repair, then remove that line immediately — leaving it on exposes a repair endpoint to the internet. Take a database backup before running it.

Verify with a real page

Load the front end, sign in to the admin, open the post editor and run a search. A home page served from cache can hide a database that is still refusing writes, so test something that reads and writes, not just the cached front page.

WP REPAIR INCIDENT STANDARD

Safe intervention sequence

The message covers several different failures: invalid credentials, an unreachable database service, exhausted connections, disk pressure or damaged tables. The order of checks prevents a configuration guess from becoming data loss.

WP RepairDiagnostic model
1Request2PHP / server3WordPress4Component
Follow the chain until you find the first point that stops behaving as expected.
  1. Confirm whether every site using the same database server is affected.
  2. Compare DB_NAME, DB_USER, DB_HOST and privileges without publishing wp-config.php.
  3. Test the same credentials directly from the hosting database tool or command line.
  4. Check disk space, connection limits and the database service log before attempting table repair.

What must be verified

  • Front end and admin queries both work.
  • A controlled write persists and can be read back.
  • No connection or crashed-table errors appear in the database log.

BEFORE YOU SEND THE REQUEST

Frequently asked questions.

Do you ask for passwords in the form?+

No. The public form never requests access. Secure credentials are requested only after the scope and quote are approved.

Who reviews the incident?+

The request goes to Jordi Ensenyat, founder of Code Barcelona and a WordPress specialist with more than 15 years of experience.

Is anything changed before the quote?+

No. Visible symptoms and scope are reviewed first. Intervention begins after approval and with a rollback path prepared.

Do you work internationally?+

Yes. WP Repair handles WordPress and WooCommerce incidents in English and Spanish through a remote service.

Assess my incident