PostgreSQL 18 is available through native distribution repositories on current Enterprise Linux releases. EL 10.2 provides versioned postgresql18-* packages, while RHEL 9.8 provides PostgreSQL 18 through the postgresql:18 module stream. This guide installs the database server on Rocky Linux, RHEL, AlmaLinux, Oracle Linux, and CentOS Stream, initializes a fresh cluster, starts the service, creates an application role and database, and optionally prepares remote access. A separate PGDG procedure is included when native packages are unavailable or when you need the community repository lifecycle.
Tested on: Rocky Linux 10.2 (Red Quartz); PostgreSQL 18.4.
postgresql-setup --initdb over an existing PostgreSQL data directory. If the server already contains PostgreSQL 16 or another major release, use a PostgreSQL major-version upgrade procedure instead of this fresh-install guide.
Prerequisites
- RHEL, Rocky Linux, AlmaLinux, Oracle Linux, or CentOS Stream with AppStream enabled, or a PGDG repository when native packages are unavailable.
- sudo command or root access for package installation, cluster initialization, and service management.
- A fresh host, or a host where the applicable native or PGDG data directory does not already contain a database cluster. The defaults are
/var/lib/pgsql/datafor native packages and/var/lib/pgsql/18/datafor PGDG packages. - Outbound network access to distribution or PGDG repositories.
Check the distribution release before you install anything. EL 10.2 provides native versioned PostgreSQL 18 packages, while RHEL 9.8 provides PostgreSQL 18 through a module stream. If PostgreSQL 18 is unavailable natively, check whether PGDG supports your exact distribution, minor release, and architecture.
Choose an install method
| Method | Best for | Jump to |
|---|---|---|
| Native distribution packages | EL 10.2 with postgresql18-server, RHEL 9.8 with the postgresql:18 module stream, and other releases that publish native PostgreSQL 18 |
Method 1 |
| PostgreSQL Yum Repository (PGDG) | Releases without native PostgreSQL 18, PGDG-only extensions, or organizations that follow the PostgreSQL community packaging lifecycle | Method 2 |
Use native distribution packages for the primary procedure in this guide because PostgreSQL 18 is available directly in current EL 10.2 repositories.
Choose PGDG when:
- PostgreSQL 18 is unavailable in your installed distribution release
- A PGDG-only extension is required
- Versioned binary and service paths are preferred
- The organization deliberately follows the PostgreSQL community packaging lifecycle
Do not enable PGDG halfway through a native-package installation.
| Item | Native EL 10.2 | Native RHEL 9.8 | PGDG (typical) |
|---|---|---|---|
| Install command | dnf install postgresql18-server |
dnf module install postgresql:18/server |
dnf install postgresql18-server |
| Setup helper | postgresql-setup --initdb |
postgresql-setup --initdb |
/usr/pgsql-18/bin/postgresql-18-setup initdb |
| Service | postgresql.service |
postgresql.service |
postgresql-18.service |
| Binary directory | /usr/bin |
/usr/bin |
/usr/pgsql-18/bin |
| Data directory | /var/lib/pgsql/data |
/var/lib/pgsql/data |
/var/lib/pgsql/18/data |
postgresql.conf |
/var/lib/pgsql/data/postgresql.conf |
/var/lib/pgsql/data/postgresql.conf |
/var/lib/pgsql/18/data/postgresql.conf |
pg_hba.conf |
/var/lib/pgsql/data/pg_hba.conf |
/var/lib/pgsql/data/pg_hba.conf |
/var/lib/pgsql/18/data/pg_hba.conf |
Native distribution streams are not intended for side-by-side installation of multiple PostgreSQL major versions. PGDG is the clearer choice when multiple versioned installations are required, although each cluster still needs its own data directory and port.
Verify paths from the installed RPM with rpm -ql postgresql18-server or rpm -ql postgresql-server, and inspect unit files with systemctl list-unit-files 'postgresql*'.
After installation, continue with verify the server, create a role and database, install extensions, configure remote access, update packages, or uninstall if you need those workflows.
Method 1: Install PostgreSQL 18 from native distribution repositories (recommended)
This is the path I tested on Rocky Linux 10.2. Native packages on EL 10.2 and RHEL 9.8 share the same initialization helper, service unit, and default data directory.
Check package availability
Identify the operating system:
cat /etc/os-releaseSample output:
NAME="Rocky Linux"
VERSION="10.2 (Red Quartz)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="10.2"
PLATFORM_ID="platform:el10"
PRETTY_NAME="Rocky Linux 10.2 (Red Quartz)"Confirm the CPU architecture:
uname -mSample output:
x86_64Refresh repository metadata without upgrading installed packages. Package discovery, module streams, and installs in this guide use the dnf command.
sudo dnf makecache --refreshA successful run commonly ends with Metadata cache created. This refreshes metadata for enabled repositories without upgrading the installed operating-system packages.
| Platform | PostgreSQL 18 native packaging |
|---|---|
| RHEL 10.2 | Versioned postgresql18-* RPM packages |
| Rocky Linux 10.2 | Versioned postgresql18-* RPM packages |
| AlmaLinux 10.2 | Versioned postgresql18-* RPM packages |
| RHEL 9.8 | postgresql:18 module stream |
| Oracle Linux 10 | Verify with dnf info postgresql18-server |
| CentOS Stream 10 | Verify with dnf info postgresql18-server |
If PostgreSQL 18 is not available natively, check these common causes:
- The system has not been updated to the required minor release
- AppStream is disabled
- Repository metadata is stale
- A pinned repository snapshot predates PostgreSQL 18
- The architecture does not have the expected package build
Exact publication timing can differ between Oracle Linux, CentOS Stream, and RHEL rebuilds.
On RHEL 9 systems, list module streams before you assume a versioned RPM name:
dnf module list postgresqlThe postgresql:18 stream should appear on RHEL 9.8. On Rocky Linux, AlmaLinux, or Oracle Linux 9, run dnf module list postgresql first because the available PostgreSQL streams can differ by distribution and minor release.
Install PostgreSQL 18 on EL 10.2 and newer
On EL 10.2 and compatible rebuilds, install the versioned server package from AppStream:
dnf info postgresql18-serverSample output:
Available Packages
Name : postgresql18-server
Version : 18.4
Release : 1.el10_2
Architecture : x86_64
Repository : appstream
Summary : The programs needed to create and run a PostgreSQL serverThe Repository: appstream line tells you the native distribution package is available on this host.
List related packages before you install:
dnf list --available 'postgresql18*'Sample output:
postgresql18.x86_64 18.4-1.el10_2 appstream
postgresql18-contrib.x86_64 18.4-1.el10_2 appstream
postgresql18-server.x86_64 18.4-1.el10_2 appstream
postgresql18-pgvector.x86_64 0.8.0-1.el10_2 appstream
postgresql18-postgis.x86_64 3.5.3-1.el10_2 appstreamThe exact extension list can vary by enabled repositories. On my Rocky Linux 10.2 host, optional packages such as postgresql18-pgvector and postgresql18-postgis appeared in AppStream, while some add-ons such as postgresql18-pg_partman were listed from EPEL.
Install the database server:
sudo dnf install -y postgresql18-serverSample output:
Installed:
postgresql18-18.4-1.el10_2.x86_64
postgresql18-private-libs-18.4-1.el10_2.x86_64
postgresql18-server-18.4-1.el10_2.x86_64
uuid-1.6.2-65.el10.x86_64
Complete!dnf also installs the client and shared libraries the server depends on.
Install PostgreSQL 18 on RHEL 9.8 using the module stream
On RHEL 9.8, PostgreSQL 18 is provided through the postgresql:18 module stream rather than a standalone postgresql18-server RPM name.
Install the server profile from that stream:
sudo dnf module install -y postgresql:18/serverOn Rocky Linux, AlmaLinux, or Oracle Linux 9, run dnf module list postgresql first because the available PostgreSQL streams can differ by distribution and minor release. After installation, both native methods use the same initialization helper and service unit shown in the next section.
Check the installed server package:
rpm -q postgresql-serverThe returned package version should begin with PostgreSQL 18 because the enabled postgresql:18 stream supplies the unversioned RPM name.
Confirm the installed native packages
On EL 10.2, the server RPM is named postgresql18-server. On RHEL 9.8 module installations, the stream usually installs packages such as postgresql-server instead. List installed PostgreSQL packages locally before you assume the EL 10.2 naming pattern.
Check the installed NEVRA and repository source on EL 10.2:
rpm -q postgresql18-serverSample output on EL 10.2:
postgresql18-server-18.4-1.el10_2.x86_64dnf info --installed postgresql18-serverSample output:
Installed Packages
Name : postgresql18-server
Version : 18.4
Release : 1.el10_2
From repo : appstreamOptionally install contrib utilities now or later in Install PostgreSQL 18 extensions:
sudo dnf install -y postgresql18-contribOn RHEL 9.8 module installations, use postgresql-contrib instead of postgresql18-contrib.
| Package pattern (EL 10.2) | Purpose |
|---|---|
postgresql18 |
Client programs and shared components |
postgresql18-server |
Database server and initialization integration |
postgresql18-contrib |
Additional PostgreSQL-supplied extensions |
postgresql18-devel |
Development files for building client software or extensions |
postgresql18-docs |
PostgreSQL documentation, where provided |
postgresql18-postgis |
PostGIS extension, where available |
postgresql18-pgvector |
Vector extension, where available |
postgresql18-pgaudit |
Audit extension, where available |
On RHEL 9.8 module installations, the equivalent names are postgresql, postgresql-server, and postgresql-contrib.
This article stops at discovering extension packages and enabling a basic contrib extension. PostGIS, pgvector, and pgAudit require additional configuration that belongs in their respective guides.
List installed files when you need to confirm paths and integration files. The rpm command covers -q and -ql when you want to inspect what the server package placed on disk.
rpm -ql postgresql18-server | head -20On RHEL 9.8 module installations:
rpm -ql postgresql-server | head -20This lists files installed by the server RPM. Use it to confirm the setup helper, systemd integration, server binaries, and packaged support files instead of assuming their locations.
Initialize and start the native PostgreSQL service
Create the first cluster with the native helper:
sudo postgresql-setup --initdbSample output:
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.logThat command creates:
- The PostgreSQL data directory
postgresql.confpg_hba.conf- Internal system catalogs
- The
postgres,template0, andtemplate1databases - The initial database superuser role named
postgres
Cluster locale, encoding, locale provider, and checksum settings are established during initialization. Check these requirements before creating the cluster because changing some of them later requires creating or migrating to another cluster.
PostgreSQL 18 changes worth noting on a fresh cluster:
- New clusters enable data page checksums by default
- MD5 password authentication is deprecated
- New configurations should prefer SCRAM authentication rather than introducing new MD5 password entries
Relocating PGDATA, WAL, or tablespaces belongs in a separate storage article. This guide uses the native default path /var/lib/pgsql/data.
Enable PostgreSQL at boot and start it now. Native and PGDG installs both rely on systemd; the systemctl command covers enable, start, restart, and reload for the PostgreSQL unit.
sudo systemctl enable --now postgresql.serviceThe service may take a second or two to accept connections on the first start. Check unit state:
systemctl status postgresql.serviceSample output:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
Active: active (running)
Main PID: 420858 (postgres)
CGroup: /system.slice/postgresql.service
└─420858 /usr/bin/postgres -D /var/lib/pgsql/dataIf startup fails, use the journalctl command to inspect recent unit output before changing configuration:
journalctl -u postgresql.service --no-pager -n 50The output should show the first initialization, permission, configuration, or port-binding error that prevented the service from starting.
Method 2: Install PostgreSQL 18 from the PGDG repository
Use this method only when native distribution packages are unavailable or when you deliberately choose PGDG. Do not mix native initialization commands with PGDG service units.
PGDG officially lists RHEL, Rocky Linux, and AlmaLinux as supported platforms on the PostgreSQL download page. On Oracle Linux or CentOS Stream, verify repository compatibility before installing the packages.
- Open the PostgreSQL downloads page and select your distribution release and CPU architecture.
- Install the current PGDG repository RPM shown on that page.
- On EL 9 systems, disable the distribution PostgreSQL module before installing PGDG packages.
- Refresh DNF metadata.
- Confirm that
postgresql18-serverwill come from PGDG before you install it. - Install the server and optional contrib packages.
- Initialize the cluster with the PGDG versioned helper.
- Enable the versioned service unit.
On EL 10 x86_64, the repository RPM currently looks like this:
sudo dnf install -y \
https://download.postgresql.org/pub/repos/yum/reporpms/EL-10-x86_64/pgdg-redhat-repo-latest.noarch.rpmUse the repository-install command generated by the PostgreSQL download page when you are using EL 9, a non-x86_64 architecture, or a different supported platform.
On EL 9 systems, disable the native PostgreSQL module after installing the PGDG repository RPM and before installing PGDG packages:
sudo dnf -qy module disable postgresqlRun this step on EL 9 before installing the PGDG packages. It disables the native PostgreSQL module so that DNF can select the versioned packages supplied by PGDG. Do not run this command on EL 10 because RHEL-family 10 does not use the same module workflow.
Confirm that the PGDG repository is enabled:
dnf repolist --enabled | grep -i pgdgSample output:
pgdg18 PostgreSQL 18 for RHEL / Rocky / AlmaLinux 10 - x86_64Refresh metadata after adding the repository:
sudo dnf makecache --refreshConfirm the server package will come from PGDG before you install it:
dnf info postgresql18-serverThe Repository field should identify PGDG, for example pgdg18, rather than appstream.
Install the server and optional contrib packages:
sudo dnf install -y postgresql18-server postgresql18-contribInitialize the cluster with the PGDG versioned helper:
sudo /usr/pgsql-18/bin/postgresql-18-setup initdbSample output:
Initializing database ... OKThe helper creates the PGDG default data directory, usually /var/lib/pgsql/18/data.
Enable the versioned service unit:
sudo systemctl enable --now postgresql-18.serviceVerify the installed paths and unit files from the RPM rather than assuming native EL paths:
rpm -ql postgresql18-server | head -20systemctl list-unit-files 'postgresql*'Do not use postgresql.service or postgresql-setup --initdb for a PGDG installation unless the installed packages actually provide those native integration tools.
After PGDG installation, continue with the shared sections below for verification, role creation, and extensions.
Verify the PostgreSQL 18 installation
Use the psql and pg_isready commands that match your package source:
| Package source | psql command |
pg_isready command |
|---|---|---|
| Native | sudo -u postgres psql |
sudo -u postgres pg_isready |
| PGDG | sudo -u postgres /usr/pgsql-18/bin/psql |
sudo -u postgres /usr/pgsql-18/bin/pg_isready |
First, check whether the server is accepting local connections:
sudo -u postgres pg_isreadyOn PGDG installations, use /usr/pgsql-18/bin/pg_isready instead.
Sample output:
/var/run/postgresql:5432 - accepting connectionspg_isready confirms that a PostgreSQL server is responding on the selected socket or address. The SQL checks that follow confirm the actual server version and runtime configuration.
Verify the running server version with SQL, not only the client binary:
sudo -u postgres psql -c 'SELECT version();'On PGDG installations:
sudo -u postgres /usr/pgsql-18/bin/psql -c 'SELECT version();'Sample output:
PostgreSQL 18.4 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 14.3.1 20251022 (Red Hat 14.3.1-4), 64-bitQuery the running server for its data directory, configuration files, port, and checksum status:
sudo -u postgres psql -c "
SELECT name, setting
FROM pg_settings
WHERE name IN (
'server_version',
'data_directory',
'config_file',
'hba_file',
'port',
'listen_addresses',
'data_checksums'
)
ORDER BY name;"On PGDG installations, use /usr/pgsql-18/bin/psql with the same query.
Sample output on a native installation:
name | setting
------------------+------------------------------------------
config_file | /var/lib/pgsql/data/postgresql.conf
data_checksums | on
data_directory | /var/lib/pgsql/data
hba_file | /var/lib/pgsql/data/pg_hba.conf
listen_addresses | localhost
port | 5432
server_version | 18.4
(7 rows)On PGDG installations, data_directory, config_file, and hba_file should point under /var/lib/pgsql/18/data.
A successful installation should show:
- Service state
active (running) pg_isreadyreporting that the server accepts connectionsserver_versionbeginning with18- Data-directory and configuration paths that match the chosen package source
psql --version reports only the client binary on your PATH, which can differ from the running server.
Create the first role and database
Open an administrative psql session as the Linux postgres user:
sudo -u postgres psqlOn PGDG installations:
sudo -u postgres /usr/pgsql-18/bin/psqlCreate an application login, set its password interactively, and create an owned database:
CREATE ROLE appuser LOGIN;
\password appuser
CREATE DATABASE appdb OWNER appuser;Sample interaction:
CREATE ROLE
Enter new password for user "appuser":
Enter it again:
CREATE DATABASEExit with \q.
List roles to confirm appuser exists:
sudo -u postgres psql -c '\du'On PGDG installations, use /usr/pgsql-18/bin/psql with the same options.
Sample output:
Role name | Attributes
-----------+------------------------------------------------------------
appuser |
postgres | Superuser, Create role, Create DB, Replication, Bypass RLSThe database listing should show appuser as the owner of appdb:
sudo -u postgres psql -c '\l appdb'Sample output:
Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges
-------+---------+----------+-----------------+-------------+-------------+--------+-----------+-------------------
appdb | appuser | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | |Keep three identities separate:
- The Linux account named
postgres - The PostgreSQL superuser role named
postgres - Application roles such as
appuser
Local socket connections often work through peer authentication when the Linux username matches the PostgreSQL role. On the tested Rocky Linux 10.2 native installation, TCP connections to 127.0.0.1 can match an ident rule while local socket connections use peer. Check the generated pg_hba.conf on your system before changing it.
Install PostgreSQL 18 extensions
Installing an extension normally has two stages:
- Install the operating-system package
- Enable the extension inside each required database
Install contrib packages if they are not already present.
For native EL 10.2 packages:
sudo dnf install -y postgresql18-contribFor the native RHEL 9.8 module stream:
sudo dnf install -y postgresql-contribFor PGDG:
sudo dnf install -y postgresql18-contribEnable an extension in a database:
sudo -u postgres psql -d appdb -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;'On PGDG installations, use /usr/pgsql-18/bin/psql with the same options.
Sample output:
CREATE EXTENSIONdnf search looks through package names and descriptions, while dnf list shows package names that match the PostgreSQL prefix for your package source.
For native EL 10.2 and PGDG:
dnf search postgresql18dnf list --available 'postgresql18*'For the native RHEL 9.8 module stream:
dnf search postgresqldnf list --available 'postgresql*'Inspect extensions known to the server:
sudo -u postgres psql -d appdb -c "
SELECT name, default_version, installed_version
FROM pg_available_extensions
WHERE name IN ('pgcrypto', 'pg_stat_statements')
ORDER BY name;"On PGDG installations, use /usr/pgsql-18/bin/psql with the same query.
Sample output:
name | default_version | installed_version
--------------------+-----------------+-------------------
pg_stat_statements | 1.12 |
pgcrypto | 1.4 | 1.4
(2 rows)A blank installed_version means the extension files are available on the server but the extension has not been enabled in appdb.
| Requirement | Likely package or extension |
|---|---|
| Cryptographic SQL functions | pgcrypto from contrib |
| Query statistics | pg_stat_statements from contrib |
| Geospatial data | PostGIS packages |
| Vector similarity search | pgvector packages |
| Database auditing | pgAudit packages |
| Procedural Python | PL/Python package |
On my Rocky Linux 10.2 host, pgcrypto was available from postgresql18-contrib and enabled successfully in appdb.
Configure remote PostgreSQL access (optional)
Skip this section when applications connect only on the local host.
Remote access needs three layers:
- PostgreSQL must listen on a network address
pg_hba.confmust authorize the client network- The host firewall must permit TCP port 5432
For native packages, edit:
/var/lib/pgsql/data/postgresql.conf
/var/lib/pgsql/data/pg_hba.confFor PGDG packages, edit:
/var/lib/pgsql/18/data/postgresql.conf
/var/lib/pgsql/18/data/pg_hba.confSet a specific listen address in postgresql.conf:
listen_addresses = '192.0.2.10'Add a narrow host rule to pg_hba.conf:
host appdb appuser 192.0.2.0/24 scram-sha-256Do not use a broad rule such as host all all 0.0.0.0/0 trust.
Validate authentication rules before you rely on them:
sudo -u postgres psql -c "SELECT line_number, type, database, user_name, address, auth_method, error FROM pg_hba_file_rules;"On PGDG installations, use /usr/pgsql-18/bin/psql with the same query.
Sample output:
line_number | type | database | user_name | address | auth_method | error
-------------+------+----------+-----------+--------------+---------------+-------
102 | host | {appdb} | {appuser} | 192.0.2.0/24 | scram-sha-256 |
(1 row)The rule is syntactically valid when the error column is empty. PostgreSQL's pg_hba_file_rules view is useful for checking authentication-file errors before relying on the new rule.
If you changed listen_addresses, restart PostgreSQL because that parameter is read only during server startup. If you changed only pg_hba.conf, a reload is sufficient.
For native packages after changing listen_addresses:
sudo systemctl restart postgresql.serviceFor PGDG packages after changing listen_addresses:
sudo systemctl restart postgresql-18.serviceWhen only pg_hba.conf was edited, reload the service. Use postgresql.service for native packages or postgresql-18.service for PGDG:
sudo systemctl reload postgresql.servicesudo systemctl reload postgresql-18.serviceOpen the default port only when remote access is required. On hosts using firewalld, see the firewalld reference for persistent port rules:
sudo firewall-cmd --permanent --add-port=5432/tcp
sudo firewall-cmd --reloadConfirm PostgreSQL is listening on the expected address with the ss command:
ss -ltn | grep ':5432'Sample output on a default local-only install:
LISTEN 0 200 127.0.0.1:5432 0.0.0.0:*
LISTEN 0 200 [::1]:5432 [::]:*After you change listen_addresses and pg_hba.conf, the socket list should include the application network address.
Test from a client host with a one-shot query:
psql -h <server-address> -U appuser -d appdb \
-c 'SELECT current_database(), current_user;'Sample output:
current_database | current_user
------------------+--------------
appdb | appuser
(1 row)An alternate PostgreSQL port may also require an SELinux port-label change. Complete SELinux and TLS configuration belong in dedicated articles.
Update PostgreSQL packages
Update installed PostgreSQL packages for your package source. The wildcard updates the server, client, libraries, and contrib package without naming every installed RPM manually.
Native EL 10.2:
sudo dnf upgrade 'postgresql18*'Native RHEL 9.8 module stream:
sudo dnf upgrade 'postgresql*'PGDG:
sudo dnf upgrade 'postgresql18*'Restart PostgreSQL after a server package update so the running processes use the newly installed server binaries.
For native packages:
sudo systemctl restart postgresql.service
sudo -u postgres psql -c 'SHOW server_version;'For PGDG packages:
sudo systemctl restart postgresql-18.service
sudo -u postgres /usr/pgsql-18/bin/psql -c 'SHOW server_version;'This handles minor package updates within PostgreSQL 18. Major-version upgrades from PostgreSQL 16 or another release belong in a dedicated upgrade article, not in this fresh-install guide.
Uninstall PostgreSQL 18
Back up any databases you need before you proceed. The commands below are source-specific.
Native EL 10.2
Stop and disable the service:
sudo systemctl disable --now postgresql.serviceRemove the packages:
sudo dnf remove -y postgresql18-server postgresql18-contrib postgresql18The next command permanently removes every database stored in the native default cluster directory. Run it only when the cluster is no longer required:
sudo rm -rf /var/lib/pgsql/dataNative RHEL 9.8 module stream
Stop and disable the service:
sudo systemctl disable --now postgresql.serviceRemove the packages:
sudo dnf remove -y postgresql-server postgresql-contrib postgresqlReset the module after the packages are removed:
sudo dnf module reset -y postgresqlResetting the module removes the selected PostgreSQL stream state after its packages have been removed.
Delete the native data directory only when the cluster is no longer required:
sudo rm -rf /var/lib/pgsql/dataPGDG
Stop and disable the versioned service:
sudo systemctl disable --now postgresql-18.serviceRemove the packages:
sudo dnf remove -y postgresql18-server postgresql18-contrib postgresql18Delete the PGDG data directory only when the cluster is no longer required:
sudo rm -rf /var/lib/pgsql/18/dataRemoving PostgreSQL 18 does not require removing the pgdg-redhat-repo package when the same repository is used for other PostgreSQL versions or extensions.
Confirm removal
Check that the service unit and packages are gone:
systemctl status postgresql.serviceSample output:
Unit postgresql.service could not be found.On PGDG installations, also check postgresql-18.service.
rpm -q postgresql18-serverSample output:
package postgresql18-server is not installedOn RHEL 9.8 module installations, check postgresql-server instead.
Troubleshoot installation and connection failures
| Symptom | Likely cause | Direction |
|---|---|---|
postgresql18-server is not found |
Release older than the required minor version, AppStream disabled, or stale metadata | Check /etc/os-release, enabled repositories, and dnf info |
dnf module install postgresql:18/server reports no matching stream |
The system is not on a release that provides the PostgreSQL 18 module | Check the OS release and run dnf module list postgresql |
postgresql-setup is not found |
PGDG packages were installed but native-package instructions are being followed | Use the PGDG versioned setup helper |
postgresql-18.service is not found |
Native packages were installed instead of PGDG packages | Use postgresql.service and inspect installed unit files |
| PostgreSQL fails to start immediately | The cluster was not initialized | Run the setup helper appropriate to the package source |
| Initialization reports a non-empty directory | An old or partial cluster already exists | Identify the existing data before taking further action |
| Port 5432 is already in use | Another PostgreSQL instance or service is listening | Inspect the socket and existing service units |
peer authentication failed |
The Linux username does not match the requested PostgreSQL role | Connect as postgres or adjust local authentication deliberately |
| Password login over TCP fails on localhost | Default pg_hba.conf still uses ident for 127.0.0.1 |
Add a narrow scram-sha-256 host rule and reload |
PostgreSQL still listens only on localhost after editing listen_addresses |
The service was reloaded rather than restarted | Restart the applicable PostgreSQL service |
| Remote connection is refused | PostgreSQL is not listening on the network address | Check listen_addresses, service state, and sockets |
| Remote connection times out | Firewall or network routing is blocking the port | Check firewalld and network reachability |
no pg_hba.conf entry appears |
No matching host authentication rule exists | Add a narrow CIDR-based rule and reload |
psql --version shows the wrong version |
A different client binary appears first in PATH |
Compare client path with SHOW server_version |
| Extension control file is missing | The matching PostgreSQL 18 extension RPM is not installed | Locate and install the correct package |
| PGDG packages have unresolved system-library dependencies | The installed EL minor release is outside the currently supported PGDG range | Update to a supported minor release and refresh metadata |
database files are incompatible with server |
The service is starting a data directory created by another PostgreSQL major version | Check the service, binary path, and PGDATA; use a documented major-upgrade procedure |
| Native packages conflict with PostgreSQL 16 | The distribution supports only one conflicting native package set | Use the documented upgrade path or containers |
References
- RHEL 10: Installing and using PostgreSQL
- RHEL 9: Using PostgreSQL and the postgresql module streams
- RHEL 9.8 release notes
- RHEL 10.2 release notes
- Rocky Linux 10.2 release announcement
- AlmaLinux 10.2 release notes
- PostgreSQL downloads for Red Hat-family Linux
- PostgreSQL 18: Creating a database cluster
- PostgreSQL 18: pg_hba.conf
- PostgreSQL 18 release notes
- PostgreSQL versioning and support policy
Summary
Choose native distribution packages when they are available: postgresql18-server on EL 10.2 or postgresql:18/server on RHEL 9.8. Initialize with postgresql-setup --initdb, start postgresql.service, and verify the running server with SQL rather than psql --version alone. Use PGDG as a separate method when native packages are unavailable, and remove the installation with dnf remove plus deletion of the data directory when you no longer need the cluster.

