phacility/phabricator · error · Exception

Unable to establish a connection to any database host (while

Error message

Unable to establish a connection to any database host (while trying "%s"). No masters or replicas are configured.

What it means

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.

Source

Thrown at src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:155

  private function raiseImproperWrite($database) {
    throw new PhabricatorClusterImproperWriteException(
      pht(
        'Unable to establish a write-mode connection (to application '.
        'database "%s") because this server is in read-only mode. Whatever '.
        'you are trying to do does not function correctly in read-only mode.',
        $database));
  }

  private function raiseImpossibleWrite($database) {
    throw new PhabricatorClusterImpossibleWriteException(
      pht(
        'Unable to connect to master database ("%s"). This is a severe '.
        'failure; your request did not complete.',
        $database));
  }

  private function raiseUnconfigured($database) {
    throw new Exception(
      pht(
        'Unable to establish a connection to any database host '.
        '(while trying "%s"). No masters or replicas are configured.',
        $database));
  }

  private function raiseUnreachable($database, Exception $proxy = null) {
    $message = pht(
      'Unable to establish a connection to any database host '.
      '(while trying "%s"). All masters and replicas are completely '.
      'unreachable.',
      $database);

    if ($proxy) {
      $proxy_message = pht(
        '%s: %s',
        get_class($proxy),
        $proxy->getMessage());

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Configure the database location: phabricator/bin/config set mysql.host <host> (plus mysql.user/mysql.pass) or define cluster.databases
  2. Ensure storage.default-namespace is also set (otherwise you will next hit 1496)
  3. Confirm the intended configuration environment is the one being loaded, then validate with phabricator/bin/storage probe / status
  4. For automated environments, make this a provisioning check that fails fast before deployment

Example fix

# before: no database hosts configured
$ phabricator/bin/storage status
# => Unable to establish a connection ... No masters or replicas are configured.

# after: minimal database configuration
phabricator/bin/config set mysql.host 127.0.0.1
phabricator/bin/config set mysql.user phab
phabricator/bin/config set mysql.pass 'secret'
phabricator/bin/config set storage.default-namespace phabricator
phabricator/bin/storage probe
Defensive patterns

Strategy: validation

Validate before calling

// Provisioning check: refuse to start work when no hosts are configured:
$databases = PhabricatorEnv::getEnvConfig('cluster.databases');
$fallback = PhabricatorEnv::getEnvConfig('mysql.host');
if (!$databases && !strlen((string)$fallback)) {
  throw new Exception(
    'No database hosts configured; set mysql.host or cluster.databases.');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/2eaf1e966261aeff. Report an issue: GitHub.