{"record":{"id":"2eaf1e966261aeff","repo":"phacility/phabricator","slug":"unable-to-establish-a-connection-to-any-database-h","errorCode":null,"errorMessage":"Unable to establish a connection to any database host (while trying \"%s\"). No masters or replicas are configured.","messagePattern":"Unable to establish a connection to any database host \\(while trying \"(.+?)\"\\)\\. No masters or replicas are configured\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/lisk/PhabricatorLiskDAO.php","lineNumber":155,"sourceCode":"  private function raiseImproperWrite($database) {\n    throw new PhabricatorClusterImproperWriteException(\n      pht(\n        'Unable to establish a write-mode connection (to application '.\n        'database \"%s\") because this server is in read-only mode. Whatever '.\n        'you are trying to do does not function correctly in read-only mode.',\n        $database));\n  }\n\n  private function raiseImpossibleWrite($database) {\n    throw new PhabricatorClusterImpossibleWriteException(\n      pht(\n        'Unable to connect to master database (\"%s\"). This is a severe '.\n        'failure; your request did not complete.',\n        $database));\n  }\n\n  private function raiseUnconfigured($database) {\n    throw new Exception(\n      pht(\n        'Unable to establish a connection to any database host '.\n        '(while trying \"%s\"). No masters or replicas are configured.',\n        $database));\n  }\n\n  private function raiseUnreachable($database, Exception $proxy = null) {\n    $message = pht(\n      'Unable to establish a connection to any database host '.\n      '(while trying \"%s\"). All masters and replicas are completely '.\n      'unreachable.',\n      $database);\n\n    if ($proxy) {\n      $proxy_message = pht(\n        '%s: %s',\n        get_class($proxy),\n        $proxy->getMessage());","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php#L137-L173","documentation":"raiseUnconfigured() throws when there are no database hosts configured at all — no masters and no replicas — for the application database the DAO is trying to reach, so there is literally nothing to connect to. Compare raiseUnreachable() directly below it, which fires when hosts ARE configured but none respond. This is a setup/bootstrap problem: the storage layer has never been configured in this environment.","triggerScenarios":"Any DAO access on a fresh install before database configuration exists; cluster.databases / mysql.host missing from the loaded configuration; running scripts or tests against a config environment (dev/prod selection) whose config file lacks the database keys; a restored or hand-built config tree missing the storage section.","commonSituations":"New deployment that skipped the storage setup step; wrong config environment selected (e.g. blank conf/ during provisioning); unit tests run without a configured sandbox; config file lost or not mounted in a container.","solutions":["Configure the database location: phabricator/bin/config set mysql.host <host> (plus mysql.user/mysql.pass) or define cluster.databases","Ensure storage.default-namespace is also set (otherwise you will next hit 1496)","Confirm the intended configuration environment is the one being loaded, then validate with phabricator/bin/storage probe / status","For automated environments, make this a provisioning check that fails fast before deployment"],"exampleFix":"# before: no database hosts configured\n$ phabricator/bin/storage status\n# => Unable to establish a connection ... No masters or replicas are configured.\n\n# after: minimal database configuration\nphabricator/bin/config set mysql.host 127.0.0.1\nphabricator/bin/config set mysql.user phab\nphabricator/bin/config set mysql.pass 'secret'\nphabricator/bin/config set storage.default-namespace phabricator\nphabricator/bin/storage probe","handlingStrategy":"validation","validationCode":"// Provisioning check: refuse to start work when no hosts are configured:\n$databases = PhabricatorEnv::getEnvConfig('cluster.databases');\n$fallback = PhabricatorEnv::getEnvConfig('mysql.host');\nif (!$databases && !strlen((string)$fallback)) {\n  throw new Exception(\n    'No database hosts configured; set mysql.host or cluster.databases.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make database configuration (mysql.host/user/pass, storage.default-namespace) the first provisioning step in every environment","Run phabricator/bin/storage probe as a deploy smoke test so missing configuration fails fast","Pin the config environment explicitly in scripts/cron so they never boot against an empty conf","Distinguish this from all-hosts-unreachable: if hosts are configured but down you get the 'unreachable' exception instead"],"tags":["configuration","cluster","setup","storage","bootstrap"],"backgroundTag":"database-not-configured","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}