zylon-ai/private-gpt · error · ConnectionError
One or more database connections failed: \n{errors}
Error message
One or more database connections failed: \n{errors} What it means
ConnectionError raised by the validate_sql closure after running check_connection() on every DatabaseQueryGenerator concurrently with asyncio.gather(return_exceptions=True). Any connection that returned an error string or raised is collected as '- DB {i} connection error: ...' lines and joined into the message.
Source
Thrown at private_gpt/components/tools/builders/database_query_builder.py:240
enable_functions=sql_artifact.enable_functions,
enable_procedures=sql_artifact.enable_procedures,
description=sql_artifact.description,
batch_size=self.settings.database_query.batch_size,
timeout_seconds=self.settings.database_query.timeout_seconds,
max_mb_result=self.settings.database_query.max_mb_result,
cache=self.cache,
)
for sql_artifact in sql_artifacts
]
validations = [gen.check_connection() for gen in query_gen]
results = list(await asyncio.gather(*validations, return_exceptions=True))
errors = [
f"- DB {i} connection error: {result!s}\n"
for i, result in enumerate(results)
if isinstance(result, str | Exception)
]
if errors:
raise ConnectionError(
"One or more database connections failed: \n" + "; ".join(errors),
)
@auto_resolve_media_blocks(blob_visibility=blob_visibility)
async def execute_sql(query: str) -> list[ResultContentBlockType]:
additional_context: str | None = await asyncio.to_thread(
self._get_additional_context,
chat_history,
)
query_gen = []
try:
query_gen = [
database_query_generator_cls(
connection_string=sql_artifact.connection_string,
ssl=sql_artifact.ssl,
schemas=sql_artifact.schemas,
enable_tables=sql_artifact.enable_tables,
enable_views=sql_artifact.enable_views,View on GitHub (pinned to 4a030776a3)
Solutions
- Read the per-DB lines in the message to identify which index failed and why (index order matches sql_artifacts order).
- Test connectivity with the same connection string using a plain client (psql/sqlcmd) or a small asyncpg/sqlalchemy script from the same host.
- Verify credentials, host, port, and ssl flag in each artifact's connection_string; install the driver extra for every engine used (e.g. uv sync --inexact --extra database-postgres).
- If failures are transient (network blip), retry after fixing network/DNS.
Defensive patterns
Strategy: retry
Validate before calling
import asyncio
async def probe_connections(sql_artifacts):
results = await asyncio.gather(*(gen.check_connection() for gen in gens), return_exceptions=True)
return [r for r in results if isinstance(r, (str, Exception)) and r not in (None, True)] Try / catch
try:
await validate_sql()
except ConnectionError as e:
errors = str(e).splitlines()
# map '- DB {i} connection error' lines back to sql_artifacts[i] and report which DB failed
raise Prevention
- Pre-check each connection_string with a lightweight client before enabling the tool.
- Keep credentials/DNS/SSL config for every artifact in sync with the database side.
- Treat transient network failures as retryable, but fix auth/config errors before retrying.
When it happens
Trigger: One or more sql_artifacts have unreachable or misconfigured connection strings: wrong host/port, bad credentials, missing SSL config, or an engine whose driver was not installed; check_connection either raises or returns an error string.
Common situations: Database behind a firewall/VPC not reachable from the app; expired or wrong password; ssl=True against a server with no TLS; using a postgres connection string in an environment where only database-mysql extra was installed.
Related errors
- Failed to inspect the database schema.
- Failed to inspect the database schema.
- Failed to inspect the database schema.
- DB2 database query dependencies are not installed. Install w
- Default LLM model '{model_id}' could not be initialized: {e}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/dbc0ab7c6119c632.
Report an issue: GitHub.