Where Is the PostgreSQL Data Directory?
PostgreSQL data dir defaults on Windows, Linux and Mac plus the SHOW data_directory query.
Last updated
PostgreSQL stores databases under a data directory holding base, pg_wal and postgresql.conf. The path carries the major version on Windows installers, so it moves every upgrade.
Ask the server itself with SHOW data_directory. That beats guides whenever packagers customized the layout.
Where PostgreSQL stores this, by platform
C:\Program Files\PostgreSQL\[Version]\data
EDB installer default with version in the path. Stop the service before file copies; use pg_dump for live backups.
/var/lib/postgresql/[Version]/main
Debian/Ubuntu layout with version and cluster name. RHEL uses /var/lib/pgsql/data instead.
/opt/homebrew/var/postgresql@[Version]
Homebrew path with version suffix. EDB Mac installs use /Library/PostgreSQL instead; check the running config.
Frequently asked questions
How do I print the real data directory?
Run SHOW data_directory in psql. It reports the path your connected server actually uses.
Can I copy the data folder as backup?
Only stopped and version matched. Logical dumps with pg_dumpall restore far more forgivingly.
Notice an outdated path? Let us know.