apache/answer · error

database connection check failed

Error message

database connection check failed

What it means

Sentinel error from initDatabase when CheckDBConnection cannot establish a working connection using the driver and connection string from config.yaml. It is a generic guard: the at-fault input is the database driver/connection configuration, and no underlying driver error is preserved — check CheckDBConnection logs for the real cause.

Source

Thrown at internal/cli/reset_password.go:264

		}
		bytes[i] = fullCharset[charIndex.Int64()]
	}

	for i := len(bytes) - 1; i > 0; i-- {
		j, err := rand.Int(rand.Reader, big.NewInt(int64(i+1)))
		if err != nil {
			return "", err
		}
		bytes[i], bytes[j.Int64()] = bytes[j.Int64()], bytes[i]
	}

	return string(bytes), nil
}

func initDatabase(driver, connection string) (*xorm.Engine, error) {
	dataConf := &data.Database{Driver: driver, Connection: connection}
	if !CheckDBConnection(dataConf) {
		return nil, fmt.Errorf("database connection check failed")
	}

	engine, err := data.NewDB(false, dataConf)
	if err != nil {
		return nil, err
	}

	return engine, nil
}

func printWarning(msg string) {
	if runtime.GOOS == "windows" {
		fmt.Printf("[WARNING] %s\n", msg)
	} else {
		fmt.Printf("\033[31m[WARNING] %s\033[0m\n", msg)
	}
}

View on GitHub (pinned to 3b9f137061)

Solutions

  1. Verify the driver and connection string passed via CLI flags (e.g., mysql/postgres driver, correct host, port, credentials)
  2. Test connectivity manually from the same host (ping, nc to the DB port, or a DB client login)
  3. Check that the database server is running and reachable (firewall, DNS, network policy)
  4. Confirm credentials in the connection string are valid and the database exists
  5. Review CheckDBConnection to see the underlying ping/timeout error it reports
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/cli/reset_password.go:264 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05). Data as JSON: /api/errors/e4c2fcc4f60a7786. Report an issue: GitHub.