Search code examples
drupaldrushddev

Drush in ddev returns BadRequestHttpException


When I try and run any drush commands within ddev (even just drush itself), I get a BadRequestHttpException. My drush version is 11.0.9 . I have tried ddev restart, ddev stop/start, and ddev delete; all have the same outcome. I ran ddev composer install too and no difference. It was working at some time, but maybe a week or so ago it just stopped. Here is the verbose response from ddev drush -vvv (sorry for the large output wall):

ddev drush -vvv
 [preflight] Config paths: /var/www/html/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /var/www/html/web/drush/sites,/var/www/html/drush/sites
 [preflight] Commandfile search paths: /var/www/html/vendor/drush/drush/src,/var/www/html/drush
 [info] Starting bootstrap to max [0.8 sec, 3.2 MB]
 [debug] Trying to bootstrap as far as we can [0.8 sec, 3.2 MB]
 [info] Drush bootstrap phase: bootstrapDrupalRoot() [0.8 sec, 3.2 MB]
 [info] Change working directory to /var/www/html/web [0.8 sec, 3.2 MB]
 [info] Initialized Drupal 9.3.14 root directory at /var/www/html/web [0.81 sec, 3.27 MB]
 [info] Drush bootstrap phase: bootstrapDrupalSite() [0.82 sec, 3.28 MB]

In DrupalKernel.php line 372:
                                                                    
  [Symfony\Component\HttpKernel\Exception\BadRequestHttpException]  
                                                                    

Exception trace:
  at /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:372
 Drupal\Core\DrupalKernel::findSitePath() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php:109
 Drush\Boot\DrupalBoot8->confPath() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php:158
 Drush\Boot\DrupalBoot8->bootstrapDoDrupalSite() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot.php:158
 Drush\Boot\DrupalBoot->bootstrapDrupalSite() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:291
 Drush\Boot\BootstrapManager->doBootstrap() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:477
 Drush\Boot\BootstrapManager->bootstrapMax() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:412
 Drush\Boot\BootstrapManager->bootstrapToPhaseIndex() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:384
 Drush\Boot\BootstrapManager->bootstrapToPhase() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 Drush\Boot\BootstrapHook->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:335
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /var/www/html/vendor/symfony/console/Command/Command.php:221
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1027
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:124
 Drush\Runtime\Runtime->doRun() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:51
 Drush\Runtime\Runtime->run() at /var/www/html/vendor/drush/drush/drush.php:72
 require() at /var/www/html/vendor/drush/drush/drush:3
 include() at /var/www/html/vendor/bin/drush:112

Failed to run drush -vvv: exit status 1

Any guidance would be helpful.


Solution

  • So what the issue turned out to be was the port in the settings.ddev.php didn't match the port that was registered to the database - it didn't match what was returned with ddev describe. I deleted the settings.ddev.php file and ran a new ddev pull with my provider to regenerate the settings file and that resynced the ports and resolved the issue.