Could not connect to the database error in WordPress

Could not connect to the database error in WordPress

A Error Occurs when you load WordPress or Admin page, This could occur one fine day or even after you have installed any plugins or some sort of changes on your wordpress blog, here below i have compiled all the possible reason and solutions as it could be helpful as i personally understand how panicking it is when you have a running blog that goes down,  i hope this helps and you would find the solutions to fix it from this post.


Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at local-host. This could mean your host’s database server is down.

* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct host-name?
* Are you sure that the database server is running?

This error suggests WordPress cannot connect to your database. Check the below settings in your wp-config.php and verify they are correct:

  • Database name
  • username
  • password
  • host

The most common mistake is the wrong host. The host by default is set to localhost, but many hosting companies require a server name for this value, once you have these settings perfect in the config.php page proceed to read this post and am sure most of you would have resolved the issue by now. ( Also check the section that says the prefix for WordPress database table in this file is WP_

VERY IMP: If  these have been thoroughly checked, then the only reason this could happen all of as sudden is ONLY that the allowed number of connections by users to database has been exceeded on the server as there is a threshold. SO the Solution for this is Leave the blog Alone and Do not mess up any settings or file or dont think of a restore or anthing,  this is the mistake made by most webmasters, so be patient and wait for a timeout of this (approximately 6 -12 hrs or sometimes 24hrs ) then the site will get back to normal automatically without doing anything !

Precautions to avoid this situation

  • Only use plugins that you require and know about
  • Install useful plugins like : WP-Cache , WP-ManageDB to repair and optimize your database and cache
  • Allow your database to be accessible to your database users only ( do not allow database user to connect from other hosts)
  • Use Auto-blog and Feed posting Plugins wisely and carefully


  1. Veloz Skate Company September 9, 2011
  2. Veloz Skate Company September 9, 2011