phacility/phabricator · error · Exception

Unable to connect to LDAP server

Error message

Unable to connect to LDAP server (%s:%d).

What it means

Runtime failure in establishConnection(): ldap_connect() returned no link identifier for the configured host and port. It means Phabricator could not open an LDAP connection at all (unreachable host, wrong port, or DNS failure).

Solutions

  1. Verify the LDAP host and port settings in the Phabricator LDAP config
  2. Test reachability from the web host (e.g. nc host 389)
  3. Check firewall rules and that the LDAP service is running
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:317 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:317

      $profiler = PhutilServiceProfiler::getInstance();
      $call_id = $profiler->beginServiceCall(
        array(
          'type' => 'ldap',
          'call' => 'connect',
          'host' => $host,
          'port' => $this->port,
        ));

      $conn = @ldap_connect($host, $this->port);

      $profiler->endServiceCall(
        $call_id,
        array(
          'ok' => (bool)$conn,
        ));

      if (!$conn) {
        throw new Exception(
          pht('Unable to connect to LDAP server (%s:%d).', $host, $port));
      }

      $options = array(
        LDAP_OPT_PROTOCOL_VERSION => (int)$this->ldapVersion,
        LDAP_OPT_REFERRALS        => (int)$this->ldapReferrals,
      );

      foreach ($options as $name => $value) {
        $ok = @ldap_set_option($conn, $name, $value);
        if (!$ok) {
          $this->raiseConnectionException(
            $conn,
            pht(
              "Unable to set LDAP option '%s' to value '%s'!",
              $name,
              $value));
        }

View on GitHub (pinned to 5720a38cfe)