ory/kratos · error

attempting to use the option 'pool_min_conns' with

Error message

attempting to use the option 'pool_min_conns' with %s, but connection pooling is not supported for this case: dsn=%s

What it means

Same validation path as the Postgres case: if the DSN scheme is sqlite or mysql and the DSN contains 'pool_min_conns=', connection setup fails immediately with this error because pooling is not supported for those drivers — the option would be meaningless or rejected. It is returned as a permanent error, so retries will not help.

Solutions

  1. Remove the 'pool_min_conns=' query parameter from the sqlite/mysql DSN.
  2. Keep pool tuning parameters only in the Postgres configuration where a pool is supported.
  3. If connection limits matter for sqlite/mysql, control them via the DB server or driver-specific settings, not this option.
  4. Grep your config/secrets templates for 'pool_min_conns' and make it Postgres-only.

Example fix

// before
dsn: mysql://user:pass@tcp(db:3306)/db?pool_min_conns=2

// after
dsn: mysql://user:pass@tcp(db:3306)/db
Defensive patterns

Strategy: validation

Validate before calling

scheme, _, _ := sqlxx.ExtractSchemeFromDSN(dsn)
if strings.Contains(dsn, "pool_min_conns=") && (scheme == "sqlite" || scheme == "mysql") {
    return fmt.Errorf("pool_min_conns is not supported for %s DSNs", scheme)
}

Try / catch

if err := connect(dsn); err != nil {
    if strings.Contains(err.Error(), "pool_min_conns") {
        return connect(stripQueryParam(dsn, "pool_min_conns"))
    }
    return err
}

Prevention

When it happens

Trigger: Setting dsn to a 'sqlite://' or 'mysql://' URL that includes '?pool_min_conns=...' (or '&pool_min_conns=...'), e.g. 'mysql://user:pass@db:3306/db?pool_min_conns=2', triggering errors.Errorf at registry_default.go:727 during connection bootstrap.

Common situations: Shared configuration templates that append pool tuning parameters for all environments, switching a deployment from Postgres to MySQL/sqlite without cleaning DSN query parameters, and copy-pasted tuning advice from Postgres-focused guides.

Related errors


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

Appendix: source

Thrown at driver/registry_default.go:727

			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 {
			m.Logger().WithError(err).Warnf("Unable to open database, retrying.")
			return errors.WithStack(err)
		}
		p, err := sql.NewPersister(m, c,

View on GitHub (pinned to b86338da04)