PostgreSQL - Debugging


sometimes PostgreSQL server might fail to start and there are no errors in systemd journal:

$ sudo journalctl -u postgresql

or else PostgreSQL service status might be active but you still cannot to server:

$ sudo systemctl status postgresql

=> try to run PostgreSQL server in the foreground to get actual errors:

$ sudo -u postgres /usr/lib/postgresql/12/bin/postgres \
  -D /var/lib/postgresql/12/main \
  -c config_file=/etc/postgresql/12/main/postgresql.conf

see the output of dpkg-query -L postgresql-12 command (shows the contents of package) for location of postgres executable.

see /etc/postgresql/12/main/postgresql.conf (data_directory configuration setting) for location of database directory (-D option).