I recently installed postgresql on my system following: https://developer.fedoraproject.org/tech/database/postgresql/about.html. All fine until i went to the second step " Controlling access to PG cluster". After doing changes to my pg_hba.conf and typing “sudo systemctl restart postgresql” it failed saying “Job for postgresql.service failed because the control process exited with error code. See “systemctl status postgresql.service” and “journalctl -xeu postgresql.service” for details.”. Output of systemctl status postgresql.service:
× postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-11-04 15:44:55 CET; 1min 16s ago
Process: 9735 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=0/SUCCESS)
Process: 9737 ExecStart=/usr/bin/postmaster -D ${PGDATA} (code=exited, status=1/FAILURE)
Main PID: 9737 (code=exited, status=1/FAILURE)
CPU: 68ms
Nov 04 15:44:55 fedora systemd[1]: Starting postgresql.service - PostgreSQL database server...
Nov 04 15:44:55 fedora postmaster[9737]: 2022-11-04 15:44:55.570 CET [9737] LOG: Log output is redirected to log collection process
Nov 04 15:44:55 fedora postmaster[9737]: 2022-11-04 15:44:55.570 CET [9737] TIP: The further log output will appear in the "log" directory.
Nov 04 15:44:55 fedora systemd[1]: postgresql.service: Main process exited, code=exited, status=1/FAILURE
Nov 04 15:44:55 fedora systemd[1]: postgresql.service: Killing process 9738 (postmaster) with signal SIGKILL.
Nov 04 15:44:55 fedora systemd[1]: postgresql.service: Failed with result 'exit-code'.
Nov 04 15:44:55 fedora systemd[1]: Failed to start postgresql.service - PostgreSQL database server.
And “journalctl -xeu postgresql.service”:
Nov 04 15:44:55 fedora systemd[1]: Failed to start postgresql.service - PostgreSQL database server.
░░ Subject: A start job for unit postgresql.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit postgresql.service has finished with a failure.
░░
░░ The job identifier is 5915 and the job result is failed.
Nov 04 15:47:06 fedora systemd[1]: Starting postgresql.service - PostgreSQL database server...
░░ Subject: A start job for unit postgresql.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit postgresql.service has begun execution.
░░
░░ The job identifier is 6128.
Nov 04 15:47:06 fedora postmaster[9849]: 2022-11-04 15:47:06.157 CET [9849] LOG: Log output is redirected to log collection process
Nov 04 15:47:06 fedora postmaster[9849]: 2022-11-04 15:47:06.157 CET [9849] TIP: The further log output will appear in the "log" directory.
Nov 04 15:47:06 fedora systemd[1]: postgresql.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit postgresql.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Nov 04 15:47:06 fedora systemd[1]: postgresql.service: Killing process 9857 (postmaster) with signal SIGKILL.
Nov 04 15:47:06 fedora systemd[1]: postgresql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit postgresql.service has entered the 'failed' state with result 'exit-code'.
Nov 04 15:47:06 fedora systemd[1]: Failed to start postgresql.service - PostgreSQL database server.
░░ Subject: A start job for unit postgresql.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit postgresql.service has finished with a failure.
░░
░░ The job identifier is 6128 and the job result is failed.
I googled the topic myself and got it to work by deleting the /var/lib/postgres/data directory and setting it up again. But now i got the same issue again. (Same error logs).
I also enabled the postgresql.service when it was still working and i ran “initdb -D /var/lib/postgres/data” as the postgres user to initalize the database cluster.
I correctly set the permissions for the directory (0700) and my /var/lib/postgres/data directory is not empty, which seemed to be the issue for most people getting the issue.