You are working away on your website happily doing your webby things. Life is good. But then you go to save a new page/post, update a plugin, or preview a page, or visit your website and see this error message:
Error establishing a database connection
Life suddenly seems not so good.
If you are a techie-geek type (like me) you know it is not the end of the world and don't freak out (cussing is more appropriate when the maddening database error occurs.) The most likely culprit is an oil-and-vinegar combination of your host provider limiting your server access and a plugin sucking up whatever "power" you have been allotted. If you are on a shared server, use WordPress with high powered plugins, you are likely to encounter this problem at some point in time.
I used to get the database error message a lot on Dreamhost, because when I update websites I do it big. I have incurred the wrath of the server gods by updating hundreds of pages on a site within a short period of time, and when updating a single page when some plugin went off and started reindexing my miste. Here are a few things that may cause this error to appear:
- Search and Replace plugins;
- NRelate (which actually removes some content temporarily from your website while it is reindexing it), or other plugins that pull related content and merge them onto your page;
- Themes with plugins that connect related content (magazine and newspaper themes typically have this feature); and
- Any other plugin that causes your database to have to be indexed or reindexed.
What You Can Do
First, relax. Your site will usually magically reappear and start working again on its own. How long that takes is up to your web hosting company. With Dreamhost it seems to be about 15 minutes or less.
- Complain to your host provider, but you may even up having to upgrade your service plan to get more server juice.
- Disable all plugins you are do not need while updating your WordPress site.
- DELETE (not just disable) all plugins you do not need. Even deactivated plugins are problematic -- they slow down site load speed and leave you more vulnerable to hackers.