Fixing The ‘Error Establishing a Database Connection’ in WordPress 2019

Fixing The 'Error Establishing a Database Connection' in WordPress 2019
  • By Colin Newcomer
  • Last updated: August 7, 2020

The longer you work with WordPress, the more likely you are to come across the dreaded ‘error establishing a database connection‘ message. This is a scary one because you’ll likely be unable to access your site (or at least part of your site) — and, if you haven’t yet gotten your head around a few fundamental concepts about servers and/or web development, you’ll probably be at a loss.

In this post, we’ll explain why this error is happening and share some steps you can take to fix it. If you’re in total freakout mode right now because it seems like your entire site disappeared — don’t worry. It’s incredibly unlikely that your site is “gone” — your site is just having trouble accessing a key part of WordPress. Once you fix the connection, your site should 100% go back to normal.

So — take a deep breath. Now, let’s go through how to fix it.

What Does ‘Error Establishing a Database Connection’ Actually Mean?

There are two main parts to your WordPress website:

  1. Your site’s files — these are files such as the core WordPress software, your theme’s templates, plugin templates, etc.
  2. Your site’s database — this is where your actual content and settings are saved.

In order for your site to work properly, your site’s files need to be able to access the content and settings in your database. When a visitor lands on one of your blog posts, for example, WordPress:

  • finds the database host
  • connects to the database
  • finds the WordPress posts table within that database
  • looks up the content it’s trying to load.

In short, the infamous ‘error establishing a database connection‘ means that WordPress cannot find this database. Your site is trying to access the database to look up the necessary content…but it can’t do that for some reason.

Why is this such a big issue? Well, in addition to the content of posts and pages, WordPress also stores a whole heap of other essential information in its database — such as its main settings, your user data, your selected theme, your widget settings, data for your active plugins, and so on. If WordPress can’t access any of the information within its database, it has no way of loading your website — that’s why you see the scary error message instead of your site.

What Is the Cause of a Database Connection Issue?

There are a number of issues that could cause a communication problem with your site’s database:

  • Incorrect database credentials (username, password, host, database)
  • Corrupted files
  • Corrupted

[…]

 



This article was written by Colin Newcomer and originally published on WinningWP.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

You have to agree to the comment policy.

Scroll to Top