{"record":{"id":"2d809806b781209d","repo":"paperclipai/paperclip","slug":"embedded-postgresql-appears-to-already-be-reachabl","errorCode":null,"errorMessage":"Embedded PostgreSQL appears to already be reachable without a pid file; reusing existing server on configured port ${configuredPort}","messagePattern":"Embedded PostgreSQL appears to already be reachable without a pid file; reusing existing server on configured port (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/index.ts","lineNumber":516,"sourceCode":"      if (!existsSync(postmasterPidFile)) return null;\n      try {\n        const pidLine = readFileSync(postmasterPidFile, \"utf8\").split(\"\\n\")[0]?.trim();\n        const pid = Number(pidLine);\n        if (!Number.isInteger(pid) || pid <= 0) return null;\n        if (!isPidRunning(pid)) return null;\n        return pid;\n      } catch {\n        return null;\n      }\n    };\n  \n    const runningPid = getRunningPid();\n    if (runningPid) {\n      logger.warn(`Embedded PostgreSQL already running; reusing existing process (pid=${runningPid}, port=${port})`);\n    } else {\n      const configuredAdminConnectionString = `postgres://paperclip:paperclip@127.0.0.1:${configuredPort}/postgres`;\n      try {\n        const actualDataDir = await getPostgresDataDirectory(configuredAdminConnectionString);\n        if (\n          typeof actualDataDir !== \"string\" ||\n          resolve(actualDataDir) !== resolve(dataDir)\n        ) {\n          throw new Error(\"reachable postgres does not use the expected embedded data directory\");\n        }\n        await ensurePostgresDatabase(configuredAdminConnectionString, \"paperclip\");\n        logger.warn(\n          `Embedded PostgreSQL appears to already be reachable without a pid file; reusing existing server on configured port ${configuredPort}`,\n        );\n      } catch {\n        const detectedPort = await detectPort(configuredPort);\n        if (detectedPort !== configuredPort) {\n          logger.warn(`Embedded PostgreSQL port is in use; using next free port (requestedPort=${configuredPort}, selectedPort=${detectedPort})`);\n        }\n        port = detectedPort;\n        logger.info(`Using embedded PostgreSQL because no DATABASE_URL set (dataDir=${dataDir}, port=${port})`);\n        const createEmbeddedPostgres = () => new EmbeddedPostgres({","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/index.ts#L498-L534","documentation":"Startup warning (logger.warn) in startServer's embedded PostgreSQL bootstrap. Fires when no pid file exists but a PostgreSQL server is already reachable on the configured port whose data directory matches; the server adopts the existing process instead of failing the port bind.","triggerScenarios":"Thrown at server/src/index.ts:443 when the library encounters an invalid state.","commonSituations":"Logged at startup when no pid file exists but a PostgreSQL server is already accepting connections on the configured embedded port.","solutions":["Informational only; the server attached to an existing embedded PostgreSQL reachable on the configured port.","If this is unexpected, check for a leftover PostgreSQL process on that port and stop it."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}