I have encountered an issue with Drush, which doesn't show many commands that should be present. When I run a command with the --debug flag, I see the following error message.

[Symfony\Component\Console\Exception\CommandNotFoundException] Command rq was not found. Drush was unable to query the database. As a result, many commands are unavailable. Re-run your command with --debug to see relevant log messages.

When I run drush sql:connect, it shows all the correct database information for the site.

I tried Drush 9.7.2, as well as Drush 10.2.2. Both versions return the same error, whenever I install Drush locally to the site, or globally.

I am trying the commands on Drupal 8.8.5, which runs on PHP 7.1.33, on macOS 10.14.6.

To add to the above, the site itself works fine. And again, these commands above show all the correct information, so it is clearly SEEING the database. This is a local (development) build, on my local machine, under MAMP 5.7.

Furthermore, when I run drush site install -vvv, I get the following error.

[preflight] Config paths: /Users/[machine name]/vendor/drush/drush/drush.yml
[preflight] Alias paths:
[preflight] Commandfile search paths: /Users/[machine name]/vendor/drush/drush/src
[debug] Bootstrap further to find site
[debug] Trying to bootstrap as far as we can
[debug] Done with bootstrap max in Application::bootstrapAndFind(): trying to find site again.

In Application.php line 230:

[Symfony\Component\Console\Exception\CommandNotFoundException] Command site was not found. Pass --root or a @siteAlias in order to run Drupal-specific commands.

Exception trace:
at /Users/[machine name]/vendor/drush/drush/src/Application.php:230 Drush\Application->bootstrapAndFind() at /Users/[machine name]/vendor/drush/drush/src/Application.php:192
Drush\Application->find() at /Users/[machine name]/vendor/symfony/console/Application.php:235
Symfony\Component\Console\Application->doRun() at /Users/[machine name]/vendor/symfony/console/Application.php:147
Symfony\Component\Console\Application->run() at /Users/[machine name]/vendor/drush/drush/src/Runtime/Runtime.php:118
Drush\Runtime\Runtime->doRun() at /Users/[machine name]/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush\Runtime\Runtime->run() at /Users/[machine name]/vendor/drush/drush/drush.php:72
require() at /Users/[machine name]/vendor/drush/drush/drush:4

It seems to say it can't find the site, which is understandable, as I am running the command to install a site.

Something is clearly wrong. I'm hoping someone can help me sort this out.

The output of drush list is the following.

Drush Commandline Tool 10.2.2

Run drush help [command] to view command-specific help. Run drush topic to read even more documentation.

Available commands: _global:browse Display a link to a given path or open link in a browser.
drupal:directory Return the filesystem path for moddules/themes and other key folders.
entity:updates Apply pending entity schema updates.
generate Generate boilerplate code for modules/plugins/services etc.
help Display usage details for a command.
list List available commands.
pm:security Check Drupal Composer packages for pending security updates.
runserver Runs PHP's built-in http server for development.
updatedb Apply any database updates required (as with running update.php).
updatedb:status List any pending database updates.
user:login Display a one time login link for user ID 1, or another user.
version Show Drush version.
cache:clear Clear a specific cache, or all Drupal caches.
cache:get Fetch a cached object and display it. > cache:rebuild Rebuild a Drupal 8 site.
cache:set Cache an object expressed in JSON or var_export() format.
cache:tags Invalidate by cache tags.
config:import Import config from a config directory. > config:pull Export and transfer config from one environment to another.
core:edit Edit drushrc, site alias, and Drupal settings.php files.
core:init Enrich the bash startup file with bash aliases and a smart command prompt.
core:rsync Rsync Drupal code or files to/from another server using ssh.
core:status An overview of the environment - Drush and Drupal.
core:topic Read detailed documentation on a given topic.
php:eval Evaluate arbitrary php code after bootstrapping Drupal (if available).
php:script Run php a script after a full Drupal bootstrap.
site:alias Show site alias details, or a list of available site aliases.
site:alias-convert Convert legacy site alias files to the new yml format.
site:install Install Drupal along with modules/themes/configuration/profile.
site:set Set a site alias that will persist for the current session.
site:ssh Connect to a Drupal site's server via SSH, and optionally run a shell command.
sql:cli Open a SQL command-line interface using Drupal's credentials.
sql:connect A string for connecting to the DB.
sql:create Create a database.
sql:drop Drop all tables in a given database.
sql:dump Exports the Drupal DB as SQL using mysqldump or equivalent.
sql:query Execute a query against a database.
sql:sync Copy DB data from a source site to a target site.

There are commands missing from the list. It appears that Drush is not connecting to the database, which is weird, because it clearly sees the database, it's clearly aware of the necessary credentials to make the connection, and Drupal itself is connecting. The commands that show up on the DRUSH LIST seem to work fine, for example drush pm:security.

[warning] One or more of your dependencies has an outstanding security update.
[notice] Try running: composer require drupal/core drupal/webform --update-with-dependencies [notice] If that fails due to a conflict then you must update one or more root dependencies.

Name Installed Version
drupal/core 8.8.4
drupal/webform 5.9.0

I'm confused on what the solution is.

This is the output of drush cr.

In Connection.php line 416:
SQLSTATE[HY000] [2002] No such file or directory

cache:rebuild [--cache-clear [CACHE-CLEAR]] [--no-cache-clear] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify] [--druplicon] [--xh-link XH-LINK] [--] <command>

This is the output of drush cr --debug.

Using the Drush script found at /Users/brianeller-mini/vendor/drush/drush/drush using proc_open
[preflight] Config paths: /Users/brianeller-mini/vendor/drush/drush/drush.yml
[preflight] Alias paths: /Users/brianeller-mini/Projects/various/docroot/drush/sites,/Users/brianeller-mini/Projects/various/drush/sites
[preflight] Commandfile search paths: /Users/brianeller-mini/vendor/drush/drush/src
[debug] Starting bootstrap to site [debug] Drush bootstrap phase 2 [debug] Try to validate bootstrap phase 2 [debug] Try to validate bootstrap phase 2 [debug] Try to bootstrap at phase 2 [debug] Drush bootstrap phase: bootstrapDrupalRoot() [debug] Change working directory to /Users/brianeller-mini/Projects/various/docroot
[debug] Initialized Drupal 8.8.4 root directory at /Users/brianeller-mini/Projects/various/docroot
[debug] Try to validate bootstrap phase 2
[debug] Try to bootstrap at phase 2
[debug] Drush bootstrap phase: bootstrapDrupalSite()
[debug] Initialized Drupal site default at sites/default

In Connection.php line 416:

[PDOException (2002)]
SQLSTATE[HY000] [2002] No such file or directory

Exception trace:

at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:416
PDO->__construct() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:416
Drupal\Core\Database\Driver\mysql\Connection::open() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/Database/Database.php:371
Drupal\Core\Database\Database::openConnection() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/Database/Database.php:166
Drupal\Core\Database\Database::getConnection() at n/a:n/a call_user_func_array() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php:79
Drupal\Component\DependencyInjection\PhpArrayContainer->createService() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php:173
Drupal\Component\DependencyInjection\Container->get() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php:265
Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php:62
Drupal\Component\DependencyInjection\PhpArrayContainer->createService() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php:173
Drupal\Component\DependencyInjection\Container->get() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/DrupalKernel.php:544
Drupal\Core\DrupalKernel->getCachedContainerDefinition() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/DrupalKernel.php:896
Drupal\Core\DrupalKernel->initializeContainer() at /Users/brianeller-mini/Projects/various/docroot/core/lib/Drupal/Core/DrupalKernel.php:477
Drupal\Core\DrupalKernel->boot() at /Users/brianeller-mini/Projects/various/docroot/core/includes/utility.inc:38
drupal_rebuild() at /Users/brianeller-mini/vendor/drush/drush/src/Commands/core/CacheCommands.php:221
Drush\Commands\core\CacheCommands->rebuild() at n/a:n/a call_user_func_array() at /Users/brianeller-mini/vendor/consolidation/annotated-command/src/CommandProcessor.php:257
Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() at /Users/brianeller-mini/vendor/consolidation/annotated-command/src/CommandProcessor.php:212
Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() at /Users/brianeller-mini/vendor/consolidation/annotated-command/src/CommandProcessor.php:178
Consolidation\AnnotatedCommand\CommandProcessor->process() at /Users/brianeller-mini/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:302
Consolidation\AnnotatedCommand\AnnotatedCommand->execute() at /Users/brianeller-mini/Projects/various/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /Users/brianeller-mini/Projects/various/vendor/symfony/console/Application.php:1000
Symfony\Component\Console\Application->doRunCommand() at /Users/brianeller-mini/Projects/various/vendor/symfony/console/Application.php:255
Symfony\Component\Console\Application->doRun() at /Users/brianeller-mini/Projects/various/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /Users/brianeller-mini/vendor/drush/drush/src/Runtime/Runtime.php:118 Drush\Runtime\Runtime->doRun() at /Users/brianeller-mini/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush\Runtime\Runtime->run() at /Users/brianeller-mini/vendor/drush/drush/drush.php:72
require() at /Users/brianeller-mini/vendor/drush/drush/drush:4

cache:rebuild [--cache-clear [CACHE-CLEAR]] [--no-cache-clear] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify] [--druplicon] [--xh-link XH-LINK] [--] <command>

  • 1
    Moshe has sent you here, github.com/drush-ops/drush/issues/4404. Though I still don't get how to reproduce this issue. What exact command did you enter? So when you run drush cr --debug the error occurs and when you run drush cr it doesn't yeah? How did you install your site? How did you install Drush? Please update your question and help us to reproduce this error. Many thanks
    – leymannx
    May 19, 2020 at 19:41
  • 2
    In stead of saying that drush sql:connect and drush status returns the correct information, show us the output. (You can mask the password if that is your concern.) And there is no "site" command - it's "site:install" ;-) Just remove that from your post. Anyway, my first guess is that you are missing the needed database modules when running PHP as CLI, not through the webserver. (the output from drush status would have told us something about this.) Does php -m return mysqli and pdo_mysql?
    – hansfn
    May 22, 2020 at 9:47
  • Check "which php" command in terminal it should not show usr/bin/php since this issue is because of wrong php path update the bash profile with the correct php path which you are using for the project.
    – Kumaresan
    Aug 8, 2021 at 16:47
  • @Kumaresan Welcome to Drupal Answers! Is there anything that makes you think the PHP path is wrong? Supposing the OP has PHP installed in two different directories, and both the PHP versions are supported by Drush, how can you say the PHP path is wrong? I take the PHP version is supported by Drush, or Drush would show some PHP errors.
    – apaderno
    Aug 11, 2021 at 13:20

1 Answer 1


You might be missing the global drush which is causing this issue. Try to install drush globally in the following path where the composer is installed - C or D:\Users<username>\AppData\Roaming\Composer

Add the following lines to your composer.json file :-

"drush/drush": "9.x"

and run

composer global update

Alternately you can also run

composer global require drush/drush:9.x

Update the path to global drush in ENV variables. Your path to drush would be :- path_to_drush

Restart your Apache or open a new terminal window to check the drush status.

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.