Where does PostgreSQL store configuration/conf files?

Viewed 653483

I have recently installed PostgreSQL on Ubuntu with the EnterpriseDB package. I can connect to the database locally, but I can't configure it because I can't find config files. I searched through entire hard drive and found only samples like pg_hba.conf.sample

Where are the PostgreSQL .conf files?

29 Answers

If you have just installed it, it is possible that locate doesn't help. In that case, the service should be running and you can run

ps aux  | grep 'postgres *-D'

to see where the postgresql-master is loading the config files from.

Print pg_hba.conf file location:

su - postgres -c "psql -t -P format=unaligned -c 'show hba_file';"

Print postgresql.conf file location:

su - postgres -c "psql -t -P format=unaligned -c 'SHOW config_file';"

On Mac OS X:

sudo find / -name postgresql.conf 

You can find other conf files by the following command:

sudo find / -name pg\*.conf

Note: See usage using man:

man find

30-07-2019

In Windows 10 pro:

C:\Program Files\PostgreSQL\11\data

nantha=# SHOW config_file;

config_file

/var/lib/postgresql/data/postgresql.conf (1 row)

nantha=# SHOW hba_file;

hba_file

/var/lib/postgresql/data/pg_hba.conf (1 row)

on MacOS Mojave where I used brew install postgresql to install, I found it here

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

I got this using the following sql command cited in this response here:

psql -U postgres -c 'SHOW config_file'

Win7, version 10 location:

C:\Program Files\PostgreSQL\10\postgresql.conf

For ubuntu 18/20, run the following command to locate your postgresql.conf file:

locate postgresql.conf

If locate is missing in your linux then run sudo apt-get install locate to install locate first.

If you have the postgres in a docker container, probably you are binding the .conf file, to find the .conf file you are using outside the docker, run docker inspect postgres11 or the postgres container name or id. That command returns a json, look for somethig like

"HostConfig": {
            "Binds": [
                "/home/my_user/postgres11/:/var/lib/postgresql/data"
            ]

If you execute SHOW config_file; and the result is in /var/lib/postgresql/data/postgresql.conf then you know the .conf file outside is in /home/my_user/postgres11/postgresql.conf, or the resulted in the property "Binds"

I located it here:

/var/lib/pgsql/9.6/data/postgresql.conf

In ubuntu, you can find

/etc/postgresql/11/main/pg_hba.conf

// after change restart it otherwise it won't be work

service postgresql restart

My installation is not default, but you can go to directory the Postgres and find subdirectory \Data.

Configuration Files C:\Postgres\Data\postgresql.conf C:\Postgres\Data\pg_hba.conf

2022-4-25 update:

Location: /Library/PostgreSQL/14/data/postgresql.conf

System: MacOS Monterey

Just for anyone who is looking for this path...

On linux default location is:

/etc/postgresql/12/main
Related