ory/hydra · error

DSN scheme postgres:// declares a PostgreSQL database but th

Error message

DSN scheme postgres:// declares a PostgreSQL database but the server is YugabyteDB. Replace the scheme with yugabyte:// (supported in Ory Enterprise License builds) so that the service picks the correct migrations and SQL dialect. Server reported: %q.

What it means

YugabyteDB also speaks the Postgres wire protocol, so a postgres:// DSN can silently connect to a YugabyteDB server. checkDialect (oryx/popx/dialect_check.go:64) detects the "-YB-" marker in version() and throws this error so the yugabyte:// scheme is used, which selects YugabyteDB-specific migrations. YugabyteDB support is only available in Ory Enterprise License builds (yugabyteDialectSupported).

Source

Thrown at oryx/popx/dialect_check.go:65

	detectedYugabyte := strings.Contains(version, yugabyteVersionMarker)
	switch {
	case declared == dbal.DriverCockroachDB && !detectedCockroach:
		return errors.Errorf(
			"DSN scheme cockroach:// declares a CockroachDB database but the server is not CockroachDB. Server reported: %q. Use a postgres:// DSN, or point the service at a CockroachDB cluster.",
			firstLine(version),
		)
	case declared == dbal.DriverYugabyteDB && !detectedYugabyte:
		return errors.Errorf(
			"DSN scheme yugabyte:// declares a YugabyteDB database but the server is not YugabyteDB. Server reported: %q. Use a DSN scheme matching the actual server, or point the service at a YugabyteDB cluster.",
			firstLine(version),
		)
	case declared == namePostgres && detectedCockroach:
		return errors.Errorf(
			"DSN scheme postgres:// declares a PostgreSQL database but the server is CockroachDB. Replace the scheme with cockroach:// so that the service picks the correct migrations and SQL dialect. Server reported: %q",
			firstLine(version),
		)
	case declared == namePostgres && detectedYugabyte && yugabyteDialectSupported:
		return errors.Errorf(
			"DSN scheme postgres:// declares a PostgreSQL database but the server is YugabyteDB. Replace the scheme with yugabyte:// (supported in Ory Enterprise License builds) so that the service picks the correct migrations. Server reported: %q",
			firstLine(version),
		)
	}
	return nil
}

func firstLine(s string) string {
	if i := strings.IndexByte(s, '\n'); i >= 0 {
		return s[:i]
	}
	return s
}

View on GitHub (pinned to 4174065ffb)

Solutions

  1. Replace the postgres:// scheme with yugabyte:// in the DSN (requires an Ory Enterprise License build)
  2. If you do not have an enterprise license, point the service at a real PostgreSQL server
  3. Confirm the target server with SELECT version(); if YugabyteDB was provisioned by mistake, switch to Postgres

Example fix

// before
DSN=postgres://user:pass@yb-host:5433/yugabyte
// after
DSN=yugabyte://user:pass@yb-host:5433/yugabyte
Defensive patterns

Strategy: validation

Validate before calling

var version string
if err := conn.RawQuery("SELECT version()").First(&version); err != nil { return err }
if strings.Contains(version, "-YB-") && conn.Dialect.Name() == "postgres" {
    return errors.New("DSN scheme must be yugabyte:// (enterprise build) for YugabyteDB")
}

Try / catch

if err := popx.VerifyDialect(ctx, conn); err != nil {
    log.Fatalf("dialect verification failed: %v", err)
}

Prevention

When it happens

Trigger: Calling VerifyDialect(ctx, conn) where the DSN scheme is postgres:// but version() contains the "-YB-" YugabyteDB marker, and pop.DialectSupported(dbal.DriverYugabyteDB) is true.

Common situations: Pointing a service at a YugabyteDB cluster using a Postgres DSN left over from a previous setup; enabling YugabyteDB in an enterprise build but not updating the scheme; test environments provisioned with YugabyteDB instead of Postgres.

Related errors


AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03). Data as JSON: /api/errors/90255da8b84bb314. Report an issue: GitHub.