Categories
All

Error Establishing Database Connection

Error Introduction

If you have been surfing the web for a while, you have at least seen this error a few times. Error Establishing a Database Connection is one of those curses that could be caused by many reasons. As a WordPress beginner, this could be awfully frustrating specially when it happened on its own without you changing anything. We ran into this issue yesterday on our own site. It took a little over 20 minutes to detect and fix the problem. While doing the research to find possible causes, we realized that there was no good article that covered everything. In this article, we will show you how to fix the error establishing a database connection in WordPress by compiling a list of solutions all in one place.

Note: Before you make any database changes, make sure you have sufficient backups.

Solution

1. Wrong Login Credentials in wp-config.php file

The very first thing to do is check to ensure your database login credentials are correct. This is by far the most common reason why the error establishing a database connection message occurs. Especially right after people migrate to a new hosting provider. The connection details for your WordPress site are stored in the wp-config.php file which is generally located at the root of your WordPress site.

2. Problems with your hosting server

It’s safe to assume that if your site was working just a minute ago (or a day ago) and now it isn’t then the fault can be on your web host’s end.

All quality hosts these days offer some form of fast-reacting support, usually through live chat.

Start by contacting that live chat, say that you’re experiencing an “error establishing a database connection” (paste the phrase), and ask:

  • if the database server is up and running with no problems, and
  • if there isn’t any spike in activity or traffic on the server right now.

In most cases, if you tell them what sort of error you’re having, they will either let you know what the cause is exactly, or they will even fix it for you.

Most importantly, they will let you know if your database is alright and whether or not there’s any suspicious activity on the server.

Videos
How to avoid this error in the future?

While there isn’t a 100% fail-proof way to protect your site against any error establishing a database connection, there are two main elements that you should have in your insurance puzzle to be at least 90% safe:

  • Quality hosting. Work only with hosts that have optimized their platforms to work with WordPress. That way, you can always count on knowledgeable support and fast help. Not to mention that you will also avoid many common WordPress problems. Here are our recommendations.
  • Have backups. Install a simple backup plugin like UpdraftPlus (it works automatically) and you should always have a working WordPress backup that you can restore in case everything else fails.

Leave a Reply