SQLSTATE F0001 FATAL Class F0: Configuration File Error

lock_file_exists lock file “…” already exists — F0001

PostgreSQL error "lock file "…" already exists" (SQLSTATE F0001): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

The server found an existing lock/PID file when starting, suggesting another postmaster may already be using the data directory or socket. PostgreSQL raises SQLSTATE F0001 (lock_file_exists).

  • Seen at startup when postmaster.pid or a socket lock file exists.
  • Protects against two postmasters sharing one data directory.
  • A stale file can remain after an unclean shutdown.

What the server log shows

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 12345) running in data directory "/var/lib/postgresql/18/main"?

Why PostgreSQL raises this — what the manual says

As Section 18.5 Shutting Down the Server explains:

A stale postmaster.pid lock file from a previous server instance is blocking startup; PostgreSQL refuses to start until it can confirm no other postmaster is using the data directory and the lingering lock file is cleared.

On startup the postmaster creates and checks postmaster.pid to ensure only one instance owns the data directory. If a lock file already exists, it refuses to start with F0001 to avoid two servers corrupting the same files.

Common causes

  • Another PostgreSQL instance is genuinely running on that data directory.
  • A stale postmaster.pid left by an unclean shutdown/crash.
  • A leftover socket lock file in /tmp.

How to fix it

  1. Verify no postmaster is running: check the PID in the hint (ps -p <pid>).
  2. If the process is gone, remove the stale postmaster.pid and start again.
  3. Never delete the lock file while a real postmaster is running on that directory.

Related & next steps

Reference: PostgreSQL 18 Section 19.3 “Shutting Down the Server”.

Was this helpful?