The pidfile written by the postmaster process is the pidfile written by the postmaster process. As well as the postmaster's PID, it contains additional information about the running instance. was added in PostgreSQL 7.0.

Usage is automatically written by the postmaster process at startup to the data directory, and is removed after a normal shutdown.

If external_pid_file is set, an additional copy of the file is written at the specified location for use by the operating system (e.g. systemd), containing just the PID.


Item Example From Notes
PID 17454 PostgreSQL 7.0  
Data directory /var/lib/pgsql/data PostgreSQL 7.1  
postmaster start timestamp 1603954420 PostgreSQL 9.1 Unix epoch
Port number 5432 PostgreSQL 9.1  
First Unix socket directory path /tmp PostgreSQL 9.1 empty if none
First [listen_addresses|[listen_address]] PostgreSQL 9.1 IP address or "*"; empty if no TCP port
shared memory key 5432001 9437184 PostgreSQL 7.1 empty on Windows
postmaster status ready PostgreSQL 10 one of starting, stopping, ready, standby

Note that the number of rows and their order may change between PostgreSQL versions.

Source code

The filename is defined in src/backend/utils/init/miscinit.c:

#define DIRECTORY_LOCK_FILE               ""

The file itself is created by function CreateLockFile(), invoked by CreateDataDirLockFile(), also in src/backend/utils/init/miscinit.c.

Relevant declarations are contained in the following file:

Change history


$ cat /var/lib/pgsql/data/
  5432001   9437184


Data directory, PostgreSQL internals

See also

external_pid_file, postmaster