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

  1. Read the appended original error to identify connection vs SQL failure
  2. Test the same connection string with psql
  3. Quote/URL-encode credentials, verify host:port and that the DB accepts connections
  4. 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

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


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/3a5f3c70fbfc1826. Report an issue: GitHub.