continuedev/continue · error · Error
Failed to query PostgreSQL database: ${error}
Error message
Failed to query PostgreSQL database: ${error} What it means
Catch-all from getContextItems in the Postgres provider: any error while connecting or running INFORMATION_SCHEMA/sample-row queries against the database is wrapped with this message. The original error is stringified into the message, so driver details (ECONNREFUSED, auth failure, relation does not exist) are visible.
Source
Thrown at core/context/providers/PostgresContextProvider.ts:103
SELECT *
FROM ${tableName}
LIMIT ${sampleRows}`);
// Create prompt from the table schema and sample rows
let prompt = `Postgres schema for database ${this.options.database} table ${tableName}:\n`;
prompt += `${JSON.stringify(tableSchema, null, 2)}\n\n`;
prompt += `Sample rows: ${JSON.stringify(sampleRowResults, null, 2)}`;
contextItems.push({
name: `${this.options.database}-${tableName}-schema-and-sample-rows`,
description: `Schema and sample rows for table ${tableName}`,
content: prompt,
});
}
return contextItems;
} catch (error) {
throw new Error(`Failed to query PostgreSQL database: ${error}`);
} finally {
}
}
async loadSubmenuItems(
_: LoadSubmenuItemsArgs,
): Promise<ContextSubmenuItem[]> {
const pool = await this.getPool();
try {
const contextItems: ContextSubmenuItem[] = [];
const tableNames = await this.getTableNames(pool);
for (const tableName of tableNames) {
contextItems.push({
id: tableName,
title: tableName,
description: `Schema from ${tableName} and ${this.options.sampleRows} sample rows.`,View on GitHub (pinned to 5522c6f44c)
Solutions
- Read the appended original error to identify connection vs SQL failure
- Test the same connection string with psql
- Quote/URL-encode credentials, verify host:port and that the DB accepts connections
- Since the provider is deprecated, switch to a Postgres MCP server
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight connectivity
const client = new Client({ connectionString });
await client.connect(); await client.end(); Try / catch
try { ... } catch (e) {
const msg = String(e);
if (/ECONNREFUSED/.test(msg)) fixHostPort();
else if (/28P01|password/.test(msg)) fixCredentials();
else throw e;
} Prevention
- Test connection strings with psql before putting them in config
- URL-encode special characters in passwords
- Keep DB credentials in env vars, not config files
When it happens
Trigger: Wrong host/port/credentials in the provider options, database unreachable, insufficient permissions on INFORMATION_SCHEMA, or a table in the query that doesn't exist.
Common situations: connectionString typo, Postgres not running or firewalled, password containing special characters unescaped in the URL, or querying a table outside the user's search_path.
Related errors
- Error getting context items from Greptile
- No MCP connection found for ${mcpId}
- Table name must be in format schema.table_name, got ${tableN
- Error fetching tags: ${e.message}
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/3a5f3c70fbfc1826.
Report an issue: GitHub.