{"record":{"id":"ba22ac6eef884c07","repo":"ory/kratos","slug":"attempting-to-use-the-option-pool-min-conns-with","errorCode":null,"errorMessage":"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","messagePattern":"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=(.+?) dbOpts\\.AllowMinPool=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"driver/registry_default.go","lineNumber":723,"sourceCode":"\t\tm.SetContextualizer(ctxer)\n\n\t\tpool, idlePool, connMaxLifetime, connMaxIdleTime, cleanedDSN := sqlcon.ParseConnectionOptions(m.l, m.Config().DSN(ctx))\n\t\tdbOpts := &pop.ConnectionDetails{\n\t\t\tURL:             sqlcon.FinalizeDSN(m.l, cleanedDSN),\n\t\t\tIdlePool:        idlePool,\n\t\t\tConnMaxLifetime: connMaxLifetime,\n\t\t\tConnMaxIdleTime: connMaxIdleTime,\n\t\t\tPool:            pool,\n\t\t\tTracerProvider:  m.Tracer(ctx).Provider(),\n\t\t}\n\n\t\tfor _, f := range o.dbOpts {\n\t\t\tf(dbOpts)\n\t\t}\n\n\t\tscheme, _, _ := sqlxx.ExtractSchemeFromDSN(dbOpts.URL)\n\t\tif !dbOpts.AllowMinPool && scheme == \"postgres\" && strings.Contains(dbOpts.URL, \"pool_min_conns=\") {\n\t\t\terr := 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)\n\t\t\treturn backoff.Permanent(err)\n\t\t}\n\t\tif (scheme == \"sqlite\" || scheme == \"mysql\") && strings.Contains(dbOpts.URL, \"pool_min_conns=\") {\n\t\t\terr := 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)\n\t\t\treturn backoff.Permanent(err)\n\t\t}\n\n\t\tm.Logger().\n\t\t\tWithField(\"pool\", pool).\n\t\t\tWithField(\"idlePool\", idlePool).\n\t\t\tWithField(\"connMaxLifetime\", connMaxLifetime).\n\t\t\tDebug(\"Connecting to SQL Database\")\n\t\tc, err := pop.NewConnection(dbOpts)\n\t\tif err != nil {\n\t\t\tm.Logger().WithError(err).Warnf(\"Unable to connect to database, retrying.\")\n\t\t\treturn errors.WithStack(err)\n\t\t}\n\t\tif err := c.Open(); err != nil {","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/driver/registry_default.go#L705-L741","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove 'pool_min_conns=' from the Postgres DSN, since the pgxpool is disabled in this deployment.","Enable the pgxpool connection pool for the deployment so the option is honored (AllowMinPool path).","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.","Verify after change that the DSN contains no pool_min_conns parameter: check the error's dsn= output."],"exampleFix":"// before\ndsn: postgres://user:pass@db:5432/kratos?sslmode=disable&pool_min_conns=4\n\n// after\ndsn: postgres://user:pass@db:5432/kratos?sslmode=disable","handlingStrategy":"validation","validationCode":"if strings.Contains(dsn, \"pool_min_conns=\") && !poolEnabled {\n    return fmt.Errorf(\"pool_min_conns requires the pgxpool to be enabled\")\n}","typeGuard":null,"tryCatchPattern":"if err := connect(dsn); err != nil {\n    if strings.Contains(err.Error(), \"pool_min_conns\") {\n        // strip the unsupported option and reconnect once\n        return connect(stripQueryParam(dsn, \"pool_min_conns\"))\n    }\n    return err\n}","preventionTips":["Keep pool tuning query params in environment-specific config, only for Postgres deployments with the pool enabled.","Review DSN query parameters when changing deployment modes or database engines.","Document that pool_min_conns is only valid with pgxpool enabled."],"tags":["database","postgres","connection-pool","config"],"backgroundTag":"invalid-config-value","analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}