Subject: Howto tell pg_ctl to use a non-default directory for config files

From: Michael Grimm <[email-masked]>
Date: Thu, 4 Jun 2026 21:54:37 +0200

Hi,

FYI: I am pretty new to PostgreSQL, and I am intending to migrate from an MariaDB/Galera cluster to PostgreSQL with either Patroni or pg_auto_failover. And, I have successfully tested a stand-alone database with my client of interest [1], both running inside a FreeBSD jail. 

Question: 
Is there a way to tell PostgreSQL to look for config files in e.g. /usr/local/etc/postgres, where normally all config files reside in FreeBSD? [2]

Thanks and regards,
Michael

[1] https://dbmail.org
[2] As an intermediate solution I am using soft links from $PGDATA to /usr/local/etc/postgres

---

From: Tom Lane <[email-masked]>
Date: Thu, 04 Jun 2026 16:02:21 -0400

> Is there a way to tell PostgreSQL to look for config files in e.g. /usr/local/etc/postgres, where normally all config files reside in FreeBSD? [2]

Typically you would say "pg_ctl -D /usr/local/etc/postgres" to point
it at the config file.  Then you would need the config file to include
data_directory and perhaps other settings pointing to wherever the
actual data files are.  See

https://www.postgresql.org/docs/current/runtime-config-file-locations.html

			regards, tom lane

---

From: Michael Grimm <[email-masked]>
Date: Thu, 4 Jun 2026 22:08:05 +0200

> https://www.postgresql.org/docs/current/runtime-config-file-locations.html

Ah! That's what I failed to find in the documentation :-(

Thanks and regards,
Michael

---

From: Ron Johnson <[email-masked]>
Date: Thu, 4 Jun 2026 16:09:11 -0400

On Thu, Jun 4, 2026 at 4:02 PM Tom Lane <[email-masked]> wrote:

> > Is there a way to tell PostgreSQL to look for config files in e.g.
> /usr/local/etc/postgres, where normally all config files reside in FreeBSD?
> [2]
>
> actual data files are.

Is it standard to point PGDATA to an etc directory instead of to the "data"
directory?

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

---

From: Tom Lane <[email-masked]>
Date: Thu, 04 Jun 2026 16:15:11 -0400

> Is it standard to point PGDATA to an etc directory instead of to the "data"

It is if you want the server's configuration files to be separate from
the data.

			regards, tom lane

---

From: arif rahman <[email-masked]>
Date: Thu, 4 Jun 2026 13:20:15 -0700

In PostgreSQL, the configuration files do not have to live inside the data directory. You can place them elsewhere and tell PostgreSQL where to find them.

# Set postgresql.conf outside the data directory
hba_file = '/usr/local/etc/postgres/pg_hba.conf’

# pg_hba.conf
For Patroni or pg_auto_failover
Use scram-sha-256

local   all             all                     peer
host    all             all     127.0.0.1/32   scram-sha-256
host    all             all     ::1/128        scram-sha-256

Then start 
postgres -D /var/db/postgres/data \
  -c config_file=/usr/local/etc/postgres/postgresql.conf

> On Jun 4, 2026, at 1:02 PM, Tom Lane <[email-masked]> wrote:
>

---

From: Michael Grimm <[email-masked]>
Date: Fri, 12 Jun 2026 22:59:10 +0200

>  -c config_file=/usr/local/etc/postgres/postgresql.conf

JFTR: that worked perfectly well.

But, I moved on to use pg_auto_failover which is very picky w.r.t. to the location of config files. Thus I will have to become used to keep config files where ever expected by the given service … shrug.

Thanks for your working setup and regards,
Michael