I'm using a Vagrant environment generated from https://puphpet.com/ for a Drupal project & it is all going well except for Drush which gives me an error any time I try running "drush cc -all", see the error below.

<h1>Additional uncaught exception thrown while handling exception.</h1><h2>Original</h2><p>PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected: SELECT 1 FROM {blocked_ips} WHERE ip = :ip; Array
[:ip] =&amp;gt;
in drupal_is_denied() (line 1933 of /var/www/includes/bootstrap.inc).</p><h2>Additional</h2><p>PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected: SELECT * FROM {system} WHERE type = &amp;#039;theme&amp;#039; OR (type = &amp;#039;module&amp;#039; AND status = 1) ORDER BY weight ASC, name ASC; Array
in system_list() (line 165 of /var/www/includes/module.inc).</p><hr />Drush command terminated abnormally due to an unrecoverable error.                                                                                                                       [error]

From what I gather the problem is that it isn't selecting a database. Does anyone know where the details for this would be stored? The Drupal site itself is connecting & using the database fine.

I'm not sure if this would cause and issue but the database details for the Drupal site are stored as an Apache environmental variable.

  • From which folder are you running the drush command? Try running it with drush -r /var/www/html status (or -r /var/www in your case) and see if that gives you anything meaning ful.
    – Rick
    Jun 30, 2015 at 20:54
  • Another thought, who owns the files? That is what user owns the files. Drush needs to be able to read settings.php
    – Rick
    Jun 30, 2015 at 20:55
  • I'm running the command from /var/www & the output I get from that command is the same as I when I run Drush cc -all.
    – Neil Nand
    Jun 30, 2015 at 21:02
  • When I run ls -l in /var/www/sites/default the line for settings.php reads -rwxrwxr-- 1 www-data www-data 26633 Jun 9 19:43 settings.php*
    – Neil Nand
    Jun 30, 2015 at 21:03

1 Answer 1


What you are seeing above is a bug in Drush where Drush cannot bootstrap the database of a Drupal site if the database credentials are correct, but the database itself is empty. To fix this problem:

  1. If your database is empty, run "drush site-install" to create a database.

  2. If your database is not empty, check the settings of your database prefix, and make sure that it is correct.

This was recently fixed in https://github.com/drush-ops/drush/pull/1442.

  • Thanks for the answer but the database isn't empty, unless you meant a specific table? When I visit the site in the browser displays all the content from the database correctly so the connection details must be correct. settings.php is pulling the connection details from an Apache environmental variable, could that cause any problems? The site works fine when accessing it through the browser, it's just Drush that doesn't.
    – Neil Nand
    Jun 30, 2015 at 22:12
  • Is the output the same if you run drush from var/www/sites/default ? B/c drush can't bootstrap correctly from just var/www b/c it does not know anything about the site yet. Jul 1, 2015 at 0:56
  • @burnsjeremy I didn't realise that, although I've just tried it & it is still giving me the same error. I've also tried running it with sudo but it didn't have any affect.
    – Neil Nand
    Jul 2, 2015 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.