How to Fix the WordPress “Error establishing a database connection” Problem (Video)

What should you do when your WordPress site shows you the classic “Error establishing a databse connection” screen? Well, first off: keep calm — don’t do anything rash! This is common, fixable, error: so don’t panic. Here’s a quick video on the problem — with some sure-fire tests to figure out what’s gone wrong, and, even more importantly: how to go about fixing it!

Let’s take a look…

How to fix the WordPress “Error establishing a database connection” issue:

Direct link to watch the video over on Vimeo.

– (note: video credits to Topher DeRosia – creator of HeroPress)

Video Transcript:

Hi! This is Topher with WinningWP. In this video we’re going to take a look at how to fix the dreaded “error establishing a database connection” in WordPress, and if you’re not sure what that means there it is. That’s my website and it says there’s an error establishing a database connection. So let’s take a look at how to fix that. There are three common reasons that you might get this error. One is that the database server is down. The database server is just a piece of software. It can crash just like any other piece of software and sometimes it happens. Sometimes it’s not actually crashed, but so overloaded that it can’t even answer. Or there could be a configuration problem in your wp-config.php file. That’s a file that lives in the main directory of WordPress and it holds your database connection information, like username and password and things like that. We’ll take a look at how to debug both of these things. if you want to know if your database server is down often it’s easiest to simply ask your host. Send them an email or fire up live chat and say “Hey! Is my database down?” and they’ll check and tell you. Now if they’re not available or you’re not able to do that you can test this yourself with a database tool. Most hosts provide a database tool and you may not be aware of it but it’s usually there. Let’s take a look at the one available in cPanel. Here’s our cPanel just type data right in this field and it brings me all kinds of database tools. And the one we want right now is called phpMyAdmin. Now if the database were down or broken or overloaded or whatever this would not even load so the mere fact that we’re looking at it means the database is up. Now if it’s heavily loaded it may load the first time but not the second or maybe third or fourth so we’ll reload and one more time and it seems really snappy and it’s reloading every time so it appears the database is up. You don’t need to know how to read anything on this page, just be able to load it and your database is working. However, if it’s down only your host can restart it. This is not something that they allow customers to have access to so if it’s down make sure you get a hold of support as quickly as you can. If your database is fine however then it could be a problem in your wp-config file. Let’s take a look at how to fix that. Here I’m already FTP’d into my host using FileZilla. On the right here is my WordPress site on the left is my local machine and right here is wp-config.php, right in the root directory public_html. So I’m going to download this and then edit this one. And in FileZilla I can right click and edit. If yours doesn’t allow that then you’ll need to edit it in some other way. So right at the top here are the four things that we need to take a look at. DB_NAME, DB_USER DB_PASSWORD and DB_HOST and we want to compare these with what our host thinks we should have. So let’s go back to our panel and still looking at our database material here we want MySQL databases. Now I have several here but that’s okay we want to compare with what’s in our file. So our DB name is eclect_ejams and you’ll note that our username is exactly the same. That’s not uncommon. So let’s go see if we can find these two on our database page. I’m going to copy that and I’m going to search for it here. So here it is under database and it’s user is the same and you can see the users down below here. So we know it’s not the username and we know it’s not the database name so it could be the password or the host name. Now the password they won’t show you and so your only option is to reset it here and then put the new one in your config file. That works very quickly, there’s no waiting so if you think it could be a password problem I recommend doing this. If it’s not the password then all that’s left is the hostname. Now the hostname can vary from hosting company to hosting company. We’re working with SiteGround here and their host names are all localhost, and if you look carefully you’ll see that localhost is spelled wrong. So I’m going to put a “t” right there and then I’m going to save this file and I’m going to my editor and then I will upload this file. And now let’s try loading our site. And there we are! WordPress is acting as it should.We can pull up the front page and there it is. So to reiterate there are three common reasons that you might get this error. The database server could be down, or overloaded, or there could be a configuration problem in your wp-config.php file. There are a few more reasons but they’re much more rare, but if you’d like to read about them there’s a link to an excellent blog post on WinningWP in the description of this video. If you’d like to learn more about WordPress check out

View more videos…

Anything to add?

By WinningWP Editorial

Run by Brin Wilson, WinningWP is an award-winning resource for people who use – you guessed it – WordPress. Follow along on Twitter and/or Facebook.
Comments (policy)
  1. Nancy Penn says:

    Thank you for this great video tutorial. I had this issue on my blog but I’m able to fix it with the help of your video. You are a life saver. Thanks for the great work you are doing on this site.

Leave a Reply

Your email address will not be published. Required fields are marked *

All comments are held for moderation. We'll only publish comments that are on topic and adhere to our Commenting Policy.