plandex-ai/plandex · error
error checking settings: %v
Error message
error checking settings: %v
What it means
During Connect, the code queries pg_settings for statement_timeout, lock_timeout, TimeZone, and idle_in_transaction_session_timeout. This error wraps a failure of that diagnostic SELECT. It indicates the connection opened but the settings-introspection query failed, so Connect aborts.
Source
Thrown at app/server/db/db.go:80
Conn.SetMaxIdleConns(5)
}
// Verify settings
type setting struct {
Name string `db:"name"`
Setting string `db:"setting"`
Unit *string `db:"unit"`
Context string `db:"context"`
}
var settings []setting
err = Conn.Select(&settings, `
SELECT name, setting, unit, context
FROM pg_settings
WHERE name IN ('statement_timeout', 'lock_timeout', 'TimeZone', 'idle_in_transaction_session_timeout')
`)
if err != nil {
return fmt.Errorf("error checking settings: %v", err)
}
s := ""
for _, setting := range settings {
unitStr := ""
if setting.Unit != nil {
unitStr = " " + *setting.Unit // Add a leading space only if there's a unit
}
s += fmt.Sprintf("- %s = %s%s (context: %s)\n", setting.Name, setting.Setting, unitStr, setting.Context)
}
log.Printf("\n\nDatabase settings:\n%s\n", s)
return nil
}
func MigrationsUp() error {
migrationsDir := "migrations"
if os.Getenv("MIGRATIONS_DIR") != "" {View on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped %v error for the concrete cause (permission, connection reset, timeout)
- Verify the DSN and that the server is a real PostgreSQL instance with pg_settings readable
- Retry MustInitDb with backoff for transient network issues
- Grant the connecting role access to pg_settings or relax the settings check
Example fix
// before
return fmt.Errorf("error checking settings: %v", err)
// after
log.Printf("settings check failed (non-fatal): %v", err) // continue if only advisory
return nil Defensive patterns
Strategy: retry
Validate before calling
var live bool
if err := Conn.Get(&live, "SELECT true"); err != nil {
return fmt.Errorf("db not usable before settings check: %v", err)
} Try / catch
if err := MustInitDb(); err != nil {
if strings.Contains(err.Error(), "error checking settings") {
time.Sleep(2 * time.Second)
return MustInitDb() // retry transient startup blips
}
return err
} Prevention
- Use a DSN with connect_timeout and a keepalive to survive proxies/pgbouncer
- Verify pg_settings is readable by the app role on managed databases
- Retry startup DB init with exponential backoff
- Confirm the backend is PostgreSQL (pg_settings exists) before connecting
When it happens
Trigger: MustInitDb -> Connect where the pg_settings SELECT fails: connection dropped after ping, insufficient privileges to read pg_settings, TLS/proxy interruptions, or statement_timeout already killing the query.
Common situations: Managed postgres (RDS/Cloud SQL) with restricted catalog access; pgbouncer/proxy idle disconnects; network blips at startup; wrong DSN pointing at a non-postgres backend.
Related errors
- error adding convo tokens: %v
- error creating postgres driver: %v
- error starting transaction: %v
- error iterating over repo locks: %v
- error validating org membership: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/459f19d606975f5c.
Report an issue: GitHub.