{"record":{"id":"3a5f3c70fbfc1826","repo":"continuedev/continue","slug":"failed-to-query-postgresql-database-error","errorCode":null,"errorMessage":"Failed to query PostgreSQL database: ${error}","messagePattern":"Failed to query PostgreSQL database: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/context/providers/PostgresContextProvider.ts","lineNumber":103,"sourceCode":"SELECT *\nFROM ${tableName}\nLIMIT ${sampleRows}`);\n\n        // Create prompt from the table schema and sample rows\n        let prompt = `Postgres schema for database ${this.options.database} table ${tableName}:\\n`;\n        prompt += `${JSON.stringify(tableSchema, null, 2)}\\n\\n`;\n        prompt += `Sample rows: ${JSON.stringify(sampleRowResults, null, 2)}`;\n\n        contextItems.push({\n          name: `${this.options.database}-${tableName}-schema-and-sample-rows`,\n          description: `Schema and sample rows for table ${tableName}`,\n          content: prompt,\n        });\n      }\n\n      return contextItems;\n    } catch (error) {\n      throw new Error(`Failed to query PostgreSQL database: ${error}`);\n    } finally {\n    }\n  }\n\n  async loadSubmenuItems(\n    _: LoadSubmenuItemsArgs,\n  ): Promise<ContextSubmenuItem[]> {\n    const pool = await this.getPool();\n\n    try {\n      const contextItems: ContextSubmenuItem[] = [];\n      const tableNames = await this.getTableNames(pool);\n\n      for (const tableName of tableNames) {\n        contextItems.push({\n          id: tableName,\n          title: tableName,\n          description: `Schema from ${tableName} and ${this.options.sampleRows} sample rows.`,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/context/providers/PostgresContextProvider.ts#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight connectivity\nconst client = new Client({ connectionString });\nawait client.connect(); await client.end();","typeGuard":null,"tryCatchPattern":"try { ... } catch (e) {\n  const msg = String(e);\n  if (/ECONNREFUSED/.test(msg)) fixHostPort();\n  else if (/28P01|password/.test(msg)) fixCredentials();\n  else throw e;\n}","preventionTips":["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"],"tags":["postgres","database","connection","catch-all"],"backgroundTag":"database-connection-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}