{"record":{"id":"d191d5406244d6eb","repo":"paperclipai/paperclip","slug":"database-mode-is-postgres-but-no-connection-string","errorCode":null,"errorMessage":"Database mode is postgres but no connection string was set; falling back to embedded PostgreSQL","messagePattern":"Database mode is postgres but no connection string was set; falling back to embedded PostgreSQL","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/index.ts","lineNumber":474,"sourceCode":"      const lines = typeof message === \"string\"\n        ? message.split(/\\r?\\n/)\n        : message instanceof Error\n          ? [message.message]\n          : [String(message ?? \"\")];\n      for (const lineRaw of lines) {\n        const line = lineRaw.trim();\n        if (!line) continue;\n        logger.info({ embeddedPostgresLog: line }, \"embedded-postgres\");\n      }\n    };\n    const logEmbeddedPostgresFailure = (phase: \"initialise\" | \"start\", err: unknown) => {\n      const recentLogs = logBuffer.getRecentLogs();\n      if (recentLogs.length > 0) {\n        logger.error(\n          {\n            phase,\n            recentLogs,\n            err,\n          },\n          \"Embedded PostgreSQL failed; showing buffered startup logs\",\n        );\n      }\n    };\n  \n    if (config.databaseMode === \"postgres\") {\n      logger.warn(\"Database mode is postgres but no connection string was set; falling back to embedded PostgreSQL\");\n    }\n  \n    const clusterVersionFile = resolve(dataDir, \"PG_VERSION\");\n    const clusterAlreadyInitialized = existsSync(clusterVersionFile);\n    const postmasterPidFile = resolve(dataDir, \"postmaster.pid\");\n    const isPidRunning = (pid: number): boolean => {\n      try {\n        process.kill(pid, 0);\n        return true;\n      } catch {","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/index.ts#L456-L492","documentation":"config.databaseMode is 'postgres' but no connection string was configured, so the server silently falls back to the embedded PostgreSQL cluster under its data directory. The API works, but data lands in local embedded storage instead of the external/managed Postgres the mode implies — a classic prod misconfiguration.","triggerScenarios":"databaseMode=postgres while the connection string env/config is unset in the server's environment — dropped container env vars, an .env file not loaded in production, or a failed secret injection.","commonSituations":"Kubernetes/Helm values missing the DB secret reference; CI and prod env divergence; dotenv files excluded from production bundles; secret-manager outages during deploy.","solutions":["Set the Postgres connection string (DATABASE_URL or the config's connection field) in the server environment and restart.","Verify inside the actual runtime: `printenv DATABASE_URL` in the container, not just locally.","If embedded was actually intended, set databaseMode to the embedded value so intent is explicit and the warn disappears.","Check the secret-provider wiring (vault/devkey) that supplies the URL."],"exampleFix":"# before (unset)\n# after\nexport DATABASE_URL=postgres://user:pass@db.internal:5432/paperclip","handlingStrategy":"validation","validationCode":"// Fail fast instead of silently falling back to embedded PG.\nif (config.databaseMode === 'postgres' && !connectionString) {\n  throw new Error('databaseMode=postgres but no connection string is set; refusing to fall back to embedded');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert DATABASE_URL is present in production container entrypoints before starting the server.","Smoke-test that the app connects to the expected host (query pg_isready or SELECT inet_server_addr()).","Keep embedded mode for dev only and set databaseMode explicitly to match intent.","Verify secret injection (vault/devkey/K8s secrets) in the deploy pipeline, not just locally."],"tags":["database","postgres","env-var","fallback","embedded"],"backgroundTag":"missing-database-url","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}