You search a Mac for pg_hba.conf or postgresql.conf and find nothing
No such file or directoryShort answer
PostgreSQL does not keep these files in /etc. By default they sit in the data directory, which depends on how it was installed. If the server runs, SHOW hba_file and SHOW config_file print the paths. If it does not, look in the Homebrew data directory under var/postgresql@version, or in the Postgres.app folder in Application Support.
Fix it fast
1Find out which cause you have
If the server is running, ask it. SHOW prints the current value of a run-time parameter, and the locations of the configuration files are parameters. Each -c runs one command.
psql -d postgres -c "SHOW config_file;" -c "SHOW hba_file;" -c "SHOW data_directory;"2Match what you see, then jump to its fix
- 1
Tutorials for Linux point at /etc/postgresql or /etc/postgres, and nothing is there on your MacYou are looking in /etc, but the files live in the data directoryFix - 2
You ran brew install postgresql@17 (or another version) and the SHOW command cannot connectPostgreSQL came from Homebrew, so the data directory is under the Homebrew prefixFix - 3
You installed from the Postgres.app download, and there is no brew servicePostgreSQL is Postgres.app, which keeps its data in Application SupportFix
- 1
What does the error look like?
No such file or directoryls: /etc/postgresql: No such file or directory
Cause 1 of 3
You are looking in /etc, but the files live in the data directory
1Check
By default all three configuration files are stored in the database cluster's data directory, and the server finds that directory through the -D option or the PGDATA environment variable. The running server knows its own paths.
psql -d postgres -c "SHOW hba_file;"
echo "$PGDATA"2Fix
Open the path that SHOW printed. After you edit pg_hba.conf, the server only rereads it on a reload, or on a restart.
# path from SHOW hba_file
open -e "/path/printed/above/pg_hba.conf"
psql -d postgres -c "SELECT pg_reload_conf();"3Verify
After the reload, the view that shows the parsed pg_hba.conf returns no row with an error.
psql -d postgres -c "SELECT line_number, error FROM pg_hba_file_rules WHERE error IS NOT NULL;"Confirmed by postgresql.org
Cause 2 of 3
PostgreSQL came from Homebrew, so the data directory is under the Homebrew prefix
1Check
Homebrew keeps the data directory in var/postgresql@<major version> below its prefix, and the formula's background service starts the server with that directory. The prefix differs between machines, so ask brew for it instead of guessing.
brew services list
ls "$(brew --prefix)/var/postgresql@17"2Fix
Read pg_hba.conf and postgresql.conf from that directory. If the directory does not exist, the cluster has not been created yet. The formula's caveats print the initdb command for it, so run exactly the line that brew info shows, then start the service.
brew info postgresql@17
brew services start postgresql@173Verify
The files are now in the directory, and SHOW hba_file from the running server prints a path inside it.
ls "$(brew --prefix)/var/postgresql@17"/*.conf
psql -d postgres -c "SHOW hba_file;"Confirmed by raw.githubusercontent.com
Cause 3 of 3
PostgreSQL is Postgres.app, which keeps its data in Application Support
1Check
Postgres.app stores the data in a folder named var-XX under Application Support, where XX is the major version. Its window has a Server Settings button that lists the files.
ls ~/Library/Application\ Support/Postgres2Fix
In Postgres.app, click Server Settings, then use Show next to the config file or the HBA file. After you edit, reload or restart the server so it rereads the file.
open ~/Library/Application\ Support/Postgres3Verify
Finder shows the var-XX folder, and the two files are inside it.
ls ~/Library/Application\ Support/Postgres/var-17/*.confConfirmed by postgresapp.com
How do I stop it coming back?
- Write down the path from SHOW hba_file once, in your project's notes, instead of searching for it each time.
- Edit pg_hba.conf with a copy open elsewhere, and check pg_hba_file_rules after a reload, because the first matching record wins.
- Keep one PostgreSQL install per machine, or note which port each one uses, so psql talks to the server whose files you edited.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Back end
Node.js gets 'no pg_hba.conf entry for host' from PostgreSQL
error: no pg_hba.conf entry for host
The server found no pg_hba.conf rule matching your connection type, address, database and user, so it denied access.
3 causes, each with a fixDatabases
PostgreSQL says postgresql.conf has errors and a setting does not apply
a changed setting does not take effect after pg_reload_conf()
PostgreSQL logs invalid settings and ignores them on reload, so a change can silently not apply.
3 causes, each with a fixDatabases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fix