DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · File Locations

external_pid_file

Writes the postmaster PID to the specified file.

  • Default: '' (empty)
  • Type: string
  • Applies: Restart required

In plain words

PostgreSQL always writes its main process ID into postmaster.pid in the data directory, where it also acts as a lock against starting two servers on the same data. external_pid_file asks for an additional file with the PID somewhere else, typically under /run, for init scripts and monitoring tools.

For DBAs and operators

Empty (default) means no extra file. Debian packages set external_pid_file = '/var/run/postgresql/18-main.pid'. The external file contains only the PID; it is written at startup and removed at clean shutdown. If it cannot be written the server prints postgres: could not write external PID file "…": Permission denied to stderr and continues starting.

postmaster.pid in the data directory is different and much more important: it holds the PID, data directory, start time, port, socket directory, listen address, shared memory key and status. Do not delete it while a server might be running. A stale one after a crash is handled automatically when no process with that PID exists any more; if the PID is in use (even by another program), startup fails with FATAL: lock file "postmaster.pid" already exists.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

Postmaster Physical layout on disk

Related parameters

data_directory config_file

All File Locations parameters