paperclipai/paperclip · error
Embedded PostgreSQL already running; reusing existing…
Error message
Embedded PostgreSQL already running; reusing existing process (pid=${runningPid}, port=${port}) What it means
Startup embedded-Postgres bootstrap found a live postmaster pid in the data dir whose pid is still running; instead of starting a second instance it reuses the existing process (warn log with pid and port).
Solutions
- Informational only; no action needed. The server reused the already-running embedded PostgreSQL process.
- If you expected a fresh database, stop the existing embedded PostgreSQL process (by pid) before restarting.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at server/src/index.ts:431 when the library encounters an invalid state.
Common situations: Logged at startup when the embedded PostgreSQL pid file points to a live process, so the existing instance is reused instead of starting a new one.
AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-08-18).
Data as JSON: /api/errors/b6ede7146ab96bf7.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/index.ts:508
const clusterAlreadyInitialized = existsSync(clusterVersionFile);
const postmasterPidFile = resolve(dataDir, "postmaster.pid");
const isPidRunning = (pid: number): boolean => {
try {
process.kill(pid, 0);
return true;
} catch {
return false;
}
};
const getRunningPid = (): number | null => {
if (!existsSync(postmasterPidFile)) return null;
try {
const pidLine = readFileSync(postmasterPidFile, "utf8").split("\n")[0]?.trim();
const pid = Number(pidLine);
if (!Number.isInteger(pid) || pid <= 0) return null;
if (!isPidRunning(pid)) return null;
return pid;
} catch {
return null;
}
};
const runningPid = getRunningPid();
if (runningPid) {
port = embeddedPostgresOwnerPort(readFileSync(postmasterPidFile, "utf8"), dataDir, runningPid);
const actualDataDir = await getPostgresDataDirectory(`postgres://paperclip:paperclip@127.0.0.1:${port}/postgres`);
if (typeof actualDataDir !== "string" || resolve(actualDataDir) !== resolve(dataDir)) {
throw new Error("Refusing to reuse PostgreSQL: its data directory belongs to another instance.");
}
logger.warn(`Embedded PostgreSQL already running; reusing existing process (pid=${runningPid}, port=${port})`);
} else {
const configuredAdminConnectionString = `postgres://paperclip:paperclip@127.0.0.1:${configuredPort}/postgres`;
try {
const actualDataDir = await getPostgresDataDirectory(configuredAdminConnectionString);
if (View on GitHub (pinned to 3f1d897a7c)