PostgreSQL raises lock_file_exists (F0001) when it finds an existing postmaster.pid lock file in the data directory, signaling another server process or a stale PID file.
PostgreSQL Error F0001 lock_file_exists means the server cannot start because a postmaster.pid lock file already exists in the data directory. Confirm no other PostgreSQL instance is running, then safely remove the stale lock file to resolve the issue.
PostgreSQL Error F0001 lock_file_exists
PostgreSQL stores a postmaster.pid file in the data directory when the server starts. The file contains the PID of the running postmaster and acts as a lock so that only one server controls a data directory.
The F0001 lock_file_exists error appears during startup when PostgreSQL detects that postmaster.pid already exists and believes another instance might be active.
The server exits immediately to protect data integrity.
The error surfaces after an operating-system crash, an unclean shutdown, or an accidental parallel start of two PostgreSQL services that share the same data directory.
It can also appear in containerized or CI environments where multiple containers mount the same volume and attempt to start PostgreSQL simultaneously.
Ignoring the lock risks data corruption because concurrent postmasters can write conflicting WAL records.
Resolving it ensures a single authoritative instance manages the cluster.
.
An abrupt power loss or kill -9 stops PostgreSQL without removing postmaster.pid, leaving a stale lock.
Systemd, Docker Compose, or manual scripts can unknowingly launch two services pointing at the same PGDATA.
Filesystem restore, incorrect chown, or readonly remount can block PID file removal, leading to a lingering lock.
Multiple containers mounting the same data directory can race to create postmaster.pid, causing the loser to emit F0001.
.
Always confirm no postgres process is running. Deleting an active PID file can corrupt data.
It resides in the cluster's data directory, pointed to by the PGDATA environment variable or initdb path.
No, deleting the PID file alone does not touch WAL. Just ensure the server was truly offline.
Galaxy surfaces startup logs in its connection panel, so engineers spot F0001 quickly and resolve it before running queries.