ory/kratos · error

attempting to use the option 'pool_min_conns' with…

Error message

attempting to use the option 'pool_min_conns' with Postgres, but the pgxpool connection pool is disabled, this will be rejected by the database: dsn=%s dbOpts.AllowMinPool=%v

What it means

When building the database connection, the registry extracts the DSN scheme and rejects a Postgres DSN that sets 'pool_min_conns=' while the pgxpool connection pool is not enabled (dbOpts.AllowMinPool is false). The pool option would be silently forwarded to the raw pgx driver, which the database rejects, so the library fails fast with a permanent error (no retry).

Solutions

  1. Remove 'pool_min_conns=' from the Postgres DSN, since the pgxpool is disabled in this deployment.
  2. Enable the pgxpool connection pool for the deployment so the option is honored (AllowMinPool path).
  3. If min-pool sizing is required, run the service in a mode/configuration that supports pgxpool, or control connection counts at the proxy/DB level.
  4. Verify after change that the DSN contains no pool_min_conns parameter: check the error's dsn= output.

Example fix

// before
dsn: postgres://user:pass@db:5432/kratos?sslmode=disable&pool_min_conns=4

// after
dsn: postgres://user:pass@db:5432/kratos?sslmode=disable
Defensive patterns

Strategy: validation

Validate before calling

if strings.Contains(dsn, "pool_min_conns=") && !poolEnabled {
    return fmt.Errorf("pool_min_conns requires the pgxpool to be enabled")
}

Try / catch

if err := connect(dsn); err != nil {
    if strings.Contains(err.Error(), "pool_min_conns") {
        // strip the unsupported option and reconnect once
        return connect(stripQueryParam(dsn, "pool_min_conns"))
    }
    return err
}

Prevention

When it happens

Trigger: Configuring dsn like 'postgres://...?pool_min_conns=2' while the pgx pool is disabled (pool_min_conns support not opted in via dbOpts.AllowMinPool), causing errors.Errorf wrapped in backoff.Permanent at registry_default.go:723 during connection establishment.

Common situations: Copying a DSN tuned for a pgxpool-enabled deployment into a standard deployment, enabling pool tuning options found in older docs or other Ory services, and configuration templates that always include pool_min_conns regardless of deployment mode.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07). Data as JSON: /api/errors/ba22ac6eef884c07. Report an issue: GitHub.

Appendix: source

Thrown at driver/registry_default.go:723

		m.SetContextualizer(ctxer)

		pool, idlePool, connMaxLifetime, connMaxIdleTime, cleanedDSN := sqlcon.ParseConnectionOptions(m.l, m.Config().DSN(ctx))
		dbOpts := &pop.ConnectionDetails{
			URL:             sqlcon.FinalizeDSN(m.l, cleanedDSN),
			IdlePool:        idlePool,
			ConnMaxLifetime: connMaxLifetime,
			ConnMaxIdleTime: connMaxIdleTime,
			Pool:            pool,
			TracerProvider:  m.Tracer(ctx).Provider(),
		}

		for _, f := range o.dbOpts {
			f(dbOpts)
		}

		scheme, _, _ := sqlxx.ExtractSchemeFromDSN(dbOpts.URL)
		if !dbOpts.AllowMinPool && scheme == "postgres" && strings.Contains(dbOpts.URL, "pool_min_conns=") {
			err := errors.Errorf("attempting to use the option 'pool_min_conns' with Postgres, but the pgxpool connection pool is disabled, this will be rejected by the database: dsn=%s dbOpts.AllowMinPool=%v", dbOpts.URL, dbOpts.AllowMinPool)
			return backoff.Permanent(err)
		}
		if (scheme == "sqlite" || scheme == "mysql") && strings.Contains(dbOpts.URL, "pool_min_conns=") {
			err := errors.Errorf("attempting to use the option 'pool_min_conns' with %s, but connection pooling is not supported for this case: dsn=%s", scheme, dbOpts.URL)
			return backoff.Permanent(err)
		}

		m.Logger().
			WithField("pool", pool).
			WithField("idlePool", idlePool).
			WithField("connMaxLifetime", connMaxLifetime).
			Debug("Connecting to SQL Database")
		c, err := pop.NewConnection(dbOpts)
		if err != nil {
			m.Logger().WithError(err).Warnf("Unable to connect to database, retrying.")
			return errors.WithStack(err)
		}
		if err := c.Open(); err != nil {

View on GitHub (pinned to b86338da04)