Last updated February 18, 2015. Created on October 12, 2013.
Edited by phdhiren, chiddicks. Log in to edit this page.

If you're seeing PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server, it's because Drupal can't connect to the database server specified in your settings.php. There are two likely reasons for this:

  1. Your MySQL database server is not responding because it has crashed or been stopped. If you have shell access to your server and command-line knowledge, check to see if the MySQL process is running and accepting connections. It may need to be restarted. Check with your hosting company or system administrator to investigate. This can happen at any time, even if you haven't made any configuration changes.
    • In many of the case, if no change done at server configuration or code level, there is possibility that Disk space of MySQL data partition is exhausted and almost fully utilized. To check quickly with df command
  2. The connection information you specified in settings.php is incorrect. Pay particular attention to the 'host' parameter as it instructs Drupal where to reach the database server. This is most likely to happen when you have moved the site to a new server or changed the server or database configuration.

Looking for support? Visit the forums, or join #drupal-support in IRC.