Error establishing a database connection in WordPress

Understand and fix the "Error establishing a database connection" message that stops your WordPress site from loading.

·4 min read

In short

"Error establishing a database connection" means WordPress cannot reach its MySQL database. In most cases, a value in the wp-config.php file is wrong: database name, username, password or host. Compare these values with the Databases tool of your hosting, correct them, then reload your site.

Is your site showing a blank page with the sentence "Error establishing a database connection"? Your content is not lost. It is still in the database, but WordPress can no longer connect to it. This guide helps you find the cause and fix it, even without deep technical knowledge.

Why does this error appear?

WordPress stores its text, pages and settings in a MySQL database. On every visit, it connects to it using the details written in the wp-config.php file. If one of them no longer matches, the connection fails and the site cannot display anything.

The most common causes are:

  • wrong credentials in wp-config.php, often after a migration or a manual edit;
  • a database that was deleted or renamed;
  • a database user password that was changed without updating wp-config.php;
  • corrupted tables after an interruption during an update;
  • a temporarily overloaded database server, which is rarer.

Before you start

  • Check whether the error affects the whole site or only the admin area (/wp-admin). If only the admin is affected, the tables may be damaged (see below).
  • If you just edited a file, installed a plugin or migrated the site, write it down: it is often the lead.
  • A backup of your hosting may already exist, see Restore a backup of your website.

Fix the error step by step

  1. Open your hosting, then Databases, and find your site's database and its user.
  2. Open the Files tool and go to the httpdocs folder.
  3. Open the wp-config.php file for editing.
  4. Compare the value of DB_NAME with the exact database name.
  5. Compare the value of DB_USER with the exact username.
  6. Check the value of DB_PASSWORD: it is the database user's password, not your WordPress password.
  7. Keep the original DB_HOST value unless support tells you otherwise.
  8. Save the file, then reload your site.

The lines to check look like this:

  • define( 'DB_NAME', 'database_name' );
  • define( 'DB_USER', 'username' );
  • define( 'DB_PASSWORD', 'password' );
  • define( 'DB_HOST', 'host' );

Watch the details: a capital letter, a space before or after the value, or a missing quote is enough to break the connection. Keep the straight single quotes around each value.

How do you check that the password is right?

Open the database in phpMyAdmin from the Databases tool, see Create a MySQL database. If you see the WordPress tables (they often start with wp_), the database exists and holds your site. If you no longer know the user's password, open a support ticket: support will help you reset it, and you then copy it into wp-config.php.

What if the admin says "One or more database tables are unavailable"?

The tables are damaged. WordPress has a built-in repair tool:

  1. Add the line define( 'WP_ALLOW_REPAIR', true ); to wp-config.php, just above the line "That's all, stop editing!".
  2. Go to yourdomain.com/wp-admin/maint/repair.php.
  3. Click Repair Database.
  4. When the repair is done, remove the line you added: otherwise anyone could run this tool.

What if nothing works?

  • Check your hosting error logs (Logs, then Error logs): they often show the exact message returned by MySQL, such as "Access denied".
  • Restore a backup taken before the error appeared, see Restore a backup of your website.
  • Open a ticket from /submitticket.php or email support@upkyo.com, mentioning what you changed recently. Support answers 24/7.

How do you stop the error from coming back?

  • Store the database details in a password manager as soon as you create it.
  • Never delete a database without checking which site uses it.
  • Run updates on a backed-up site, see Update WordPress, plugins and themes.
  • When migrating, update wp-config.php with the new hosting details.

Frequently asked questions

Have I lost my website content?

Almost never. The error means WordPress cannot reach the database, not that the database is empty. Once the connection details are fixed, the site comes back exactly as it was.

Where is the wp-config.php file?

At the root of your WordPress installation, usually directly in the httpdocs folder. You can open it with the Files tool in the client area or over SFTP, see Connect with FTP or SFTP.

Is the database password the same as my WordPress password?

No. DB_PASSWORD is the password of the database's MySQL user. Your WordPress administrator password is different and plays no part here.

Why did the error appear after a migration?

The new hosting uses a different database, user or password from the old one. The copied wp-config.php file still holds the old values: replace them with the new ones.

The error comes and goes, is that normal?

An intermittent error can come from a traffic spike or a plugin opening too many connections. Note when it happens and open a ticket: support can check the server logs.

Next guideSpeed up a slow WordPress site

Web hosting, email and servers on high-availability infrastructure.

write to ussupport@upkyo.com
what now

Switch hosts without losing a thing.

Our engineers move your website, email and domains for you. Leave your email and we will get back to you.

© 2026 upkyo / 1178 broadway, 3rd floor, new york, ny 10001, usafr / es / legal center / legal notice / terms of service / privacy / domain registration agreement