PostgreSQL Failed to Start or Unit Not Found on AlmaLinux and RHEL
日本語 / English
When PostgreSQL reports Failed to start or Unit not found, first identify the installed service and read its logs. On AlmaLinux and RHEL, distribution packages and PostgreSQL’s PGDG packages commonly use different service names.
This guide follows the AlmaLinux 9 and RHEL 9 package-based setup covered in the Japanese article. PostgreSQL 16 is an example for PGDG commands. Use the version and paths installed on your server.
Find the installed service first
systemctl list-unit-files --type=service | grep -i postgres
rpm -qa | grep -i '^postgresql'
Compare the results before trying a start command.
| Installation | Typical service | Server package |
|---|---|---|
| Distribution packages | postgresql.service |
postgresql-server |
| PGDG PostgreSQL 16 example | postgresql-16.service |
postgresql16-server |
The listed units take priority over these examples. Containers, source builds and other Linux distributions can use different startup methods.
Fix Unit psql.service not found
psql is the command-line client used to connect to a running database. Standard PostgreSQL packages use a server service such as the names above.
If your command was systemctl start psql.service, select the actual server unit from the list. For distribution packages, inspect it with the following commands.
sudo systemctl status postgresql.service --no-pager -l
sudo journalctl -u postgresql.service -b -n 100 --no-pager
For PGDG PostgreSQL 16, substitute postgresql-16.service in both commands. A failed status command can return a nonzero exit code while still displaying useful diagnostics.
Read the error behind Failed to start
A message saying that the control process exited with an error code identifies a failed startup attempt. Read the detailed journal entries and the PostgreSQL server log, if configured, to find the cause.
| Log message | Next check |
|---|---|
| Directory is missing or empty | Confirm the data path and whether this is a new cluster. |
| Unit could not be found | Check the unit name and installed server package. |
| Lock file or postmaster.pid already exists | Check for a running server using that data directory. |
| Permission denied | Inspect the path, ownership and SELinux labels. |
| Address already in use | Find the process listening on the configured port. |
If the server package is missing
dnf list installed 'postgresql*'
A working psql command can mean that only the client is installed. For a distribution-package server, the package installation command is below. Confirm your intended package source and version before proceeding.
sudo dnf install postgresql-server
For PGDG packages, use the PostgreSQL download page’s setup instructions for your distribution, release and architecture. Mixing package sources can create confusing paths and service names.
Initialize only a genuinely new cluster
Before initialization, confirm the configured data directory and check for existing data, a restored backup or a missing storage mount. An empty-looking path on a previously working server needs investigation. Keep a verified backup before making changes to an existing installation.
For a fresh distribution-package installation, after verifying that no existing cluster needs preserving, initialize once and start the service.
sudo postgresql-setup --initdb
sudo systemctl start postgresql.service
For a fresh PGDG PostgreSQL 16 installation, the equivalent example is below.
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
sudo systemctl start postgresql-16.service
Use only the command pair matching your installation. On an existing server, inspect systemctl cat for the actual unit and review its environment and configuration before deciding which data directory is in use.
If a PID file or port conflict appears
ps -ef | grep '[p]ostgres'
sudo ss -ltnp | grep ':5432'
Port 5432 is the default example. Check your configured port if it differs. Match any running process to its service and data directory. A PID file may belong to a live server. Investigate its recorded process and the startup logs before changing it. Stopping a working database interrupts its clients, so coordinate any planned restart.
If permissions or SELinux prevent startup
For the distribution’s usual data path, inspect ownership and security labels.
sudo ls -ldZ /var/lib/pgsql /var/lib/pgsql/data
sudo journalctl -u postgresql.service -b -n 100 --no-pager
For a different data path or unit, use the actual values. Restoring a backup or moving a cluster can leave ownership or SELinux policy inconsistent with the service. Correct the specific mismatch using your distribution’s database documentation. Custom paths may need a persistent SELinux file-context rule.
Verify startup and a local connection
sudo systemctl is-active postgresql.service
sudo -u postgres psql -d postgres -c 'SELECT version();'
Use the actual service name. active confirms its running state, and a returned version confirms that this local connection succeeds. If your cluster uses a custom port or socket directory, specify it explicitly and check that you reached the intended instance.
If the server should start automatically at boot, enable the actual service after confirming the setup.
sudo systemctl enable postgresql.service
Official references
- PostgreSQL packages for the Red Hat family
- Red Hat Enterprise Linux 9 — Using PostgreSQL
- PostgreSQL 16 — Starting the database server
- PostgreSQL 16 — psql
Official documentation reviewed on November 24, 2026. Commands were reviewed against the documented package workflows. They were not executed on a fresh server for this English edition.
Found this helpful?
You can leave a small tip to support 1NUX.
Tips are optional. This guide stays free to read.
Payments are processed by codoc in Japanese yen (JPY).