hasura/graphql-engine · error
no connected databases found in the server
Error message
no connected databases found in the server
What it means
DatabaseChooserUI returns this when the metadata parsed successfully but the sources list is empty — the Hasura instance has no connected databases to offer in the select prompt. It is a user-facing interactive-flow error, not a parse failure.
Source
Thrown at cli/internal/metadatautil/sources.go:159
}
if len(sources) == 0 {
return nil, internalerrors.E(op, ErrNoConnectedSources)
}
return sources, nil
}
func DatabaseChooserUI(exportMetadata func() (io.Reader, error)) (string, error) {
var op internalerrors.Op = "metadatautil.DatabaseChooserUI"
sources, err := GetSources(exportMetadata)
if err != nil {
return "", internalerrors.E(op, fmt.Errorf("unable to get available databases: %w", err))
}
if len(sources) == 0 {
return "", internalerrors.E(op, errors.New("no connected databases found in the server"))
}
databaseName, err := util.GetSelectPrompt("Select a database to use", sources)
if err != nil {
return "", internalerrors.E(op, fmt.Errorf("error in selecting a database to use: %w", err))
}
return databaseName, nil
}
const ChooseAllDatabases = "All (all available databases)"
func DatabaseChooserUIWithAll(exportMetadata func() (io.Reader, error)) (string, error) {
var op internalerrors.Op = "metadatautil.DatabaseChooserUIWithAll"
sources, err := GetSources(exportMetadata)
if err != nil {
return "", internalerrors.E(op, fmt.Errorf("unable to get available databases: %w", err))View on GitHub (pinned to 724551b9ae)
Solutions
- Connect a database to the Hasura instance (hasura db add / console)
- Verify HASURA_GRAPHQL_ENDPOINT and admin secret target the intended instance
- If expecting sources, export metadata and confirm the sources array is populated
Example fix
// before
db, err := metadatautil.DatabaseChooserUI(exportMetadata)
if err != nil { return err }
// after
db, err := metadatautil.DatabaseChooserUI(exportMetadata)
if err != nil && strings.Contains(err.Error(), "no connected databases") {
return fmt.Errorf("connect a database first (hasura db add), then re-run")
}
if err != nil { return err } Defensive patterns
Strategy: validation
Validate before calling
sources, err := metadatautil.GetSources(exportMetadata)
if err == nil && len(sources) == 0 {
// skip chooser, tell user to connect a database
} Try / catch
if err != nil && strings.Contains(err.Error(), "no connected databases") {
// friendly guidance
} Prevention
- Pre-check sources with GetSources
- Ensure a database is connected before running interactive commands
When it happens
Trigger: Running any command that triggers the database selection prompt against a Hasura server with zero connected sources. The prompt cannot be shown because there is nothing to select.
Common situations: New/fresh Hasura instance before any database is added; wrong endpoint (querying an empty dev instance instead of the populated one); sources removed during cleanup.
Related errors
- 0 connected sources found on hasura
- unable to get available databases: %w
- error in selecting a database to use: %w
- error in getting user input: %w
- error in selecting framework: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/052425b9cd86b50c.
Report an issue: GitHub.