Introducing Dragonfly Cloud! Learn More

Question: Where is the postgresql.conf file located on a Mac?

Answer

The location of the postgresql.conf file in a PostgreSQL installation on macOS can vary depending on how PostgreSQL was installed. Below are common methods used to install PostgreSQL on a Mac and where you might find the postgresql.conf file for each.

Homebrew

If you installed PostgreSQL via Homebrew, a popular package manager for macOS, your configuration files are likely located in a directory linked to /usr/local/var/postgres. Specifically, the postgresql.conf file will be here:

/usr/local/var/postgres/postgresql.conf

You can also use the pg_config command to find the directory where your configuration files are stored:

pg_config --sysconfdir

Postgres.app

Postgres.app is a standalone PostgreSQL server that can be run as an application on macOS. If you've used this method, your postgresql.conf file is typically found inside the data directory of the application, which can be opened from the app's menu: "Open Database". Navigate through the folders in the Finder window that opens to locate the postgresql.conf file.

MacPorts

If you have installed PostgreSQL via MacPorts, the postgresql.conf file is generally placed under the MacPorts installation directory. The default path usually is:

/opt/local/var/db/postgresqlXX/defaultdb/postgresql.conf

Here, XX is the version number of PostgreSQL.

Manual Installation

If you have manually compiled and installed PostgreSQL, the location of postgresql.conf depends on the specified --prefix or --datadir during configuration. You can check these locations by running:

pg_config --sysconfdir

Always ensure you have appropriate permissions to view or edit the postgresql.conf file.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.