Many times, the postgresql service can't restart after some configuration changes.

Is there any command line tool allowing to check the syntax of pg_hba.conf and other pg *.conf files before reloading/restarting the service, or even better, after any config change ?


You can run:

postgres=# SELECT pg_reload_conf();
(1 row)


.. from within psql. or kill -HUP the postmaster process.

Any config validation errors will then get put into the Postgres log file, and it won't reload the config. Example log:

2016-10-05 10:31:57 BST LOG:  received SIGHUP, reloading configuration files
2016-10-05 10:31:57 BST LOG:  invalid connection type "awdawdawdawd"
2016-10-05 10:31:57 BST CONTEXT:  line 1 of configuration file "/etc/postgresql/9.3/main/pg_hba.conf"
2016-10-05 10:31:57 BST WARNING:  pg_hba.conf not reloaded

I'm not aware of a tool that just checks config for validity, but there was a thread on the pgsql-hackers mailing list here that discussed a proposal for a validator.

  • Thank you @Phil, and even more for the pgsql-hackers mailing list link ;-) – Rémi B. Oct 5 '16 at 14:10
  • It is not true. After reload conf with "t" in result I have this line in the postgres log: [9692]LOG: configuration file "/var/lib/pgsql/data/postgresql.conf" contains errors; unaffected changes were applied – Dmitry Shost Aug 28 '19 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.