GrepBoard/Manuals
605 manuals ·

pg_hba.conf was not reloaded: one bad line keeps the old rules

·Tested on PostgreSQL 17.11 (Docker postgres:17) · 2026-10·Test scope ↓·6 steps

pg_hba.conf was not reloaded means one bad line made PostgreSQL discard the whole new file. Find it with pg_hba_file_rules, fix it, and reload again.

output
LOG:  received SIGHUP, reloading configuration filesLOG:  could not open file "/var/lib/postgresql/data/users.txt": No such file or directoryCONTEXT:  line 65 of configuration file "/var/lib/postgresql/data/pg_hba.conf"LOG:  invalid CIDR mask in address "192.0.2.0/33"CONTEXT:  line 3 of configuration file "/var/lib/postgresql/data/pg_hba.conf"…LOG:  /var/lib/postgresql/data/pg_hba.conf was not reloaded

pg_hba.conf was not reloaded means the new file had at least one bad line, so the server refused the entire file. Not just the broken line is skipped: every change is ignored, and the server keeps accepting connections with the rules it had before. Find the bad lines with the pg_hba_file_rules view, fix them, and reload again.

To check a file before it reaches a server, paste it into the pg_hba.conf checker.

[1] Always read the server log after a reload. SELECT pg_reload_conf() returns t to say the signal was sent; it does not tell you whether the file was accepted (an example of old rules staying in force is in PostgreSQL Peer authentication failed, step 6). The log gets one LOG: line per bad line plus a CONTEXT: line with its line number, and ends with was not reloaded. A test file seeded with many deliberate mistakes produced 38 CONTEXT: lines. As above, the @ file error (line 65) was printed before line 3, so sort by line number when reading.

[2] Preview with pg_hba_file_rules before reloading. The view reads the file currently on disk, not the rules the server last loaded, so check it after editing and before calling reload. By default only superusers can read it. Part of the result for the test file, queried in place before the reload:

console
$ psql -X -AtF $'\t' -d postgres -c "SELECT line_number, coalesce(type,''), coalesce(array_to_string(database, ','),''), coalesce(array_to_string(user_name, ','),''), coalesce(address,''), coalesce(netmask,''), coalesce(auth_method,''), coalesce(array_to_string(options, ','),''), coalesce(error,'') FROM pg_hba_file_rules ORDER BY line_number"2	host	all	all	192.0.2.0	255.255.0.0	scram-sha-256		3								invalid CIDR mask in address "192.0.2.0/33"…22								…35								invalid authentication method "MD5"…49	host	db1	app	all		md5		50								invalid authentication method "host"52	host	all	all	.example.com		md5		…65								could not open file "/var/lib/postgresql/data/users.txt": No such file or directory…67								invalid IP mask "md5": Name or service not known68	host	all	all	8.0.0.1	255.255.255.255	md5		

Day to day, SELECT line_number, error FROM pg_hba_file_rules WHERE error IS NOT NULL; is enough, with one catch, covered next.

[3] Treat a row with an empty error and every other column empty as an error too. Line 22 above is one. PostgreSQL 17.11 produced three such rows, and all three did log an error on reload:

LineWritten in the fileReload log
22md5 clientcert=1invalid value for clientcert: "1"
43radius radiusservers=a radiussecrets=bcould not translate RADIUS server name "a" to address: …
59md5 clientname=XXinvalid value for clientname: "XX"

So add OR auth_method IS NULL to the check, or confirm in the log after reloading that was not reloaded is absent. The view and the log also worded one error differently. Line 18 (cert clientcert=verify-ca) read clientcert can only be set to "verify-full" when using "cert" authentication in the view and clientcert only accepts "verify-full" when using "cert" authentication in the log. Search for both when looking up the message.

[4] Learn the errors whose text points somewhere else:

ErrorActual cause
invalid authentication method "host" (line 50)A trailing \ on line 50 joined the next line, so the first word of line 51, host, landed in the method field. Line 51 disappeared from the view
invalid IP mask "md5" (line 67)The address was written short, as 10.1. It was accepted as an address, so the next field, md5, was read as a mask. Line 9, 192.0.2.0 with no mask, gave the same message
invalid authentication method "MD5"Method names are lower case only
invalid authentication method "sspi": not supported by this buildsspi and bsd are not in this Linux build
could not open file ".../users.txt"The file named by @users.txt is missing. Relative paths are resolved from the directory holding pg_hba.conf

A trailing \ can also appear when an editor strips trailing spaces after it. When an error names a word from the next line, as on line 50, look at the end of the previous line.

[5] Also check for lines that load without error but mean something else. The view shows no error, the reload succeeds, and the rule does not do what you intended:

run/valid-01.conf
…host    db1 ,app  all   md5…host    all  all  010.0.0.1/32      md5…
  • Line 49, db1 ,app: the space before the comma split the fields, so the database became db1, the user app, and the address all (row 49 in [2]). Just deleting the space gives host db1,app all md5, which has only four fields — now it is a syntax error and the whole reload fails. Rewrite it as a full five-field line: host db1,app <user> <allowed address> md5, filling in the user and address range the line was meant to allow.
  • Line 68, 010.0.0.1: the leading zero made it octal, so it became 8.0.0.1 (row 68 in [2]). Don't zero-pad addresses.

Neither shows up in the reload log, so after fixing, compare the view's database, user_name, and address columns with what you meant.

[6] Reload again and verify. After SELECT pg_reload_conf(); (or pg_ctl reload), check that the log has no was not reloaded, then make a new connection and confirm it hits the intended line by the line number log_connections reports: Which pg_hba.conf line matched. Keep one admin session open while you change rules, so a bad rule can be rolled back from it. On Windows, per the docs, changes apply to new connections immediately without a reload.

Official sources: pg_hba.conf · pg_hba_file_rules · log_connections

Check it with the pg_hba.conf rule checker tool ↗ — calculated in your browser.

#postgresql#pg_hba#reload#pg_hba_file_rules