{"action":"created","issue":{"url":"https://api.github.com/repos/drush-ops/drush/issues/1232","labels_url":"https://api.github.com/repos/drush-ops/drush/issues/1232/labels{/name}","comments_url":"https://api.github.com/repos/drush-ops/drush/issues/1232/comments","events_url":"https://api.github.com/repos/drush-ops/drush/issues/1232/events","html_url":"https://github.com/drush-ops/drush/issues/1232","id":60005088,"number":1232,"title":"Uncaught exception 'Drupal\\Core\\Database\\ConnectionNotDefinedException'","user":{"login":"valkum","id":169155,"avatar_url":"https://avatars.githubusercontent.com/u/169155?v=3","gravatar_id":"","url":"https://api.github.com/users/valkum","html_url":"https://github.com/valkum","followers_url":"https://api.github.com/users/valkum/followers","following_url":"https://api.github.com/users/valkum/following{/other_user}","gists_url":"https://api.github.com/users/valkum/gists{/gist_id}","starred_url":"https://api.github.com/users/valkum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valkum/subscriptions","organizations_url":"https://api.github.com/users/valkum/orgs","repos_url":"https://api.github.com/users/valkum/repos","events_url":"https://api.github.com/users/valkum/events{/privacy}","received_events_url":"https://api.github.com/users/valkum/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-05T19:45:03Z","updated_at":"2015-03-05T19:58:13Z","closed_at":"2015-03-05T19:58:13Z","body":"I've got a problem. Somehow the database settings set in my site-alias are not set for drupal.\r\n\r\nThis is my error:\r\n```\r\nvalkum@server2:/var/www/news.page.com/sites/default$ drush @prod status\r\nPHP Fatal error:  Uncaught exception 'Drupal\\Core\\Database\\ConnectionNotDefinedException' with message 'The specified database connection is not defined: default' in /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php:366\r\nStack trace:\r\n#0 /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php(171): Drupal\\Core\\Database\\Database::openConnection('default', 'default')\r\n#1 /var/www/news.page.com/sites/default/files/php/service_container/service_container_prod/d22d714c78c5d5a7f279061e951e6e29625f03fbe25769e8e8360cd0f1da25a4.php(2345): Drupal\\Core\\Database\\Database::getConnection('default')\r\n#2 /var/www/news.page.com/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php(326): Drupal\\Core\\DependencyInjection\\Container\\prod\\service_container_prod->getDatabaseService()\r\n#3 /var/www/news.page.com/sites/default/files/php/service_container/service_container_prod/d22d714c78c5d5a7f279061e951e6e29625f03fbe25769e8e8360cd0f1da25a4.php( in /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php on line 366\r\nPHP Fatal error:  Uncaught exception 'Drupal\\Core\\Database\\ConnectionNotDefinedException' with message 'The specified database connection is not defined: default' in /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php:366\r\nStack trace:\r\n#0 /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php(171): Drupal\\Core\\Database\\Database::openConnection('default', 'default')\r\n#1 /var/www/news.page.com/sites/default/files/php/service_container/service_container_prod/d22d714c78c5d5a7f279061e951e6e29625f03fbe25769e8e8360cd0f1da25a4.php(2345): Drupal\\Core\\Database\\Database::getConnection('default')\r\n#2 /var/www/news.page.com/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php(326): Drupal\\Core\\DependencyInjection\\Container\\prod\\service_container_prod->getDatabaseService()\r\n#3 /var/www/news.page.com/sites/default/files/php/service_container/service_container_prod/d22d714c78c5d5a7f279061e951e6e29625f03fbe25769e8e8360cd0f1da25a4.php( in /var/www/news.page.com/core/lib/Drupal/Core/Database/Database.php on line 366\r\n\r\n```\r\nIn my settings.php for that site i have:\r\n```\r\n$db_creds = unserialize(getenv('DRUPAL_DB'));\r\nif($db_creds != false) {\r\n  $databases = array (\r\n    'default' => array (\r\n      'default' => $db_creds,\r\n    ),\r\n  );\r\n  $databases['default']['default']['namespace'] = 'Drupal\\\\Core\\\\Database\\\\Driver\\\\mysql';\r\n}\r\n```\r\nDRUPAL_DB is set in my vhost file via SetEnv and contains an Database array with my credentials.\r\nMy site-alias file:\r\n```\r\n$aliases['prod'] = array(\r\n  'uri' => 'news.page.com',\r\n  'root' => '/var/www/news.page.com',\r\n  'os' => 'Linux',\r\n  'db-url' => 'mysql://news_page:defaced@localhost/news_page'\r\n  'databases' =>\r\n  array (\r\n    'default' =>\r\n    array (\r\n      'driver' => 'mysql',\r\n      'username' => 'news_page',\r\n      'password' => 'defaced',\r\n      'port' => '',\r\n      'host' => 'localhost',\r\n      'database' => 'news_page',\r\n      'namespace' => 'Drupal\\\\Core\\\\Database\\\\Driver\\\\mysql',\r\n    ),\r\n  ),\r\n);\r\n```\r\nSeems strange. Normally the $databases variable should be overwritten with the one from the file alias, or am i wrong?"},"comment":{"url":"https://api.github.com/repos/drush-ops/drush/issues/comments/77439453","html_url":"https://github.com/drush-ops/drush/issues/1232#issuecomment-77439453","issue_url":"https://api.github.com/repos/drush-ops/drush/issues/1232","id":77439453,"user":{"login":"weitzman","id":7740,"avatar_url":"https://avatars.githubusercontent.com/u/7740?v=3","gravatar_id":"","url":"https://api.github.com/users/weitzman","html_url":"https://github.com/weitzman","followers_url":"https://api.github.com/users/weitzman/followers","following_url":"https://api.github.com/users/weitzman/following{/other_user}","gists_url":"https://api.github.com/users/weitzman/gists{/gist_id}","starred_url":"https://api.github.com/users/weitzman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weitzman/subscriptions","organizations_url":"https://api.github.com/users/weitzman/orgs","repos_url":"https://api.github.com/users/weitzman/repos","events_url":"https://api.github.com/users/weitzman/events{/privacy}","received_events_url":"https://api.github.com/users/weitzman/received_events","type":"User","site_admin":false},"created_at":"2015-03-05T19:58:13Z","updated_at":"2015-03-05T19:58:13Z","body":"The alias db-url is not used for all commands. It is mainly only used for sql-* commands. Otherwise, Drupal bootstraps itself and the error you get happens because virtual hosts are not in play for CLI requests. \r\n\r\nFortunately, you can pass ENV variables in an alias. See #955. Requires Drush7. Once you pass that, I think you can remove db-url and databases from the alias if you want."}}