OMG My Blog Won’t Load!

WordPress will not load

There is never any warning.

You wake up one morning and check your blog stats for the previous night, or perhaps you’re checking from your tablet while sat in a coffee shop. But the effect is always the same.

The blog won’t load, and there is nothing you can do about it.

It’s one of the problems of paying for hosting and support rather than ploughing money into your own local server and super-fast Internet connection. Naturally, it’s the route most of us take, as the “control freak” option is ridiculously expensive.

So your blog sits there, inaccessible to you and your readers, leaving you at the whim (and sometimes mercy) of your web host’s tech support department. Will you rely on them – or should you attempt to fix the problem yourself?

Error Establishing a Database Connection

There are various errors that you might experience when trying to open your blog, but one of the most common – and inexplicable – is “Error establishing a database connection.” Whether you had your blog open a few moments before or haven’t looked at it all weekend, the message displayed by the site gives little away.

All you can ascertain is that there is a connection issue and that the server itself is up and running – if not, the WordPress-styled error message page wouldn’t appear.

Any of the following might be the cause for the error message:

  • Your database login credentials are incorrect.
  • Your credentials have been changed.
  • The database server is unresponsive.
  • The database has been corrupted.

If you suspect that any of these are to blame, you can attempt to resolve the issue yourself, without waiting for your web host.

Note, however, that if you don’t have any joy with the following steps you should contact tech support and wait for their response. It might be that they have a server outage that they are dealing with, so also take a moment to check on your web hosts status page or Twitter account – after all, you don’t want to be wasting time trying to fix the problem only to find that it “fixes itself” in the meantime, do you?

Time to Troubleshoot

The first thing you should check is whether the problem is affecting the entire site. If you checked the blog as a user would see it, try logging into the WordPress dashboard via the wp-admin route (www.mysite.com/wp-admin) – in many cases the error message will be the same, but if a fix is available, you will be informed here.

“One or more database tables are unavailable. The database may need to be repaired,” is the message you might see instead, in which case you should access your site via FTP and open the wp-config.php file.

Here, you will need to add the following line:

define('WP_ALLOW_REPAIR', true);

Save the file, upload it to the server (overwriting the previous wp-config.php) and then open the repair.php tool (via the file path www.mysite.com/wp-admin/maint/repair.php).

Use the options offered to repair the database, but once you’re done remember to remove the line you added to wp-config.php for security purposes.

More From WP-Config

Arguably the most important file in your WordPress installation, wp-config.php acts as a central repository of instructions and login credentials that manage your blog works.

For instance, if your database username and password are set as incorrect value in wp-config.php, you will see the “Error connecting to database” message. To check, open wp-config.php and check the following values are correct:

define('DB_NAME', 'database_name');
define('DB_USER', 'database_username');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'localhost');

(In your wp-config.php, the values ‘database_name’, ‘database_username’ nad ‘database_password’ should display your own settings, of course.)

Incidentally, changing the ‘localhost’ value to display your server’s IP address may work, but you should reset the change once the issue is resolved with your website’s tech support.

Do You Have Any Fixes?

These fixes will work in the majority of cases, but of course every WordPress installation is slightly different.

As such, don’t be disappointed to learn that these suggestions don’t fix your database connection problems. You might, for example, need to run some MySQL commands to diagnose and repair the issue – something that we’ll take a look at in future.

In the meantime, let us know how you deal with the “Error connecting to database” message.

Leave a Reply

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

You May Also Like...