
If you run a web application, manage a development environment, or operate a Linux server, you need a reliable database engine behind it. PostgreSQL is the most capable open-source relational database available today, and knowing how to install PostgreSQL on Fedora 43 correctly is a skill every developer and sysadmin should have locked down.
Fedora 43 ships with a significant update: it bundles PostgreSQL 18 as the default stream, skipping version 17 entirely from the previous release cycle. That jump matters because it changes how upgrades work for existing Fedora users, and it means you get access to PostgreSQL 18’s improvements including incremental backups, virtual generated columns, and smarter query planning right out of the box.
This guide covers everything you need to go from a fresh Fedora 43 system to a fully running, configured, and secured PostgreSQL 18 database server. You will get two installation methods, proper initialization steps, configuration file walkthroughs, firewall setup, SELinux guidance, and a troubleshooting section for the errors that actually come up in real deployments.
Whether you are setting up a local development database or building a production Linux server tutorial you can repeat across machines, this guide gives you the exact commands, the expected outputs, and the reasoning behind every step.
What Is PostgreSQL and Why It Belongs on Fedora 43
PostgreSQL is a free, open-source object-relational database management system (ORDBMS) with over 35 years of active development behind it. It is fully ACID-compliant, supports JSON and JSONB natively, offers full-text search, and handles everything from small personal projects to multi-terabyte production workloads.
Fedora 43 is an excellent host for PostgreSQL for a few concrete reasons. First, Fedora uses DNF5 as its package manager, which resolves dependencies faster and more cleanly than older DNF versions. Second, Fedora enforces SELinux in Enforcing mode by default, which adds a real security layer around your database without extra configuration from you. Third, Fedora 43 ships PostgreSQL 18 directly in its official repos, so you do not need a third-party repository just to get a current version.
PostgreSQL 18 brings several practical improvements over PostgreSQL 16 (the version that shipped in earlier Fedora releases):
- Incremental backups reduce backup windows on large databases
- Virtual generated columns simplify schema design
- Improved query planner statistics speed up complex analytical queries
- Better logical replication handling for high-availability setups
For developers building with Django, Rails, Laravel, or any framework that supports PostgreSQL, Fedora 43 is a solid, modern foundation.
Prerequisites
Before you run a single command, confirm your environment meets these requirements:
- Operating system: Fedora 43 (Workstation or Server edition)
- User privileges: A user account with
sudoaccess, or direct root access - Internet connection: Required to download packages from Fedora repos
- Minimum hardware: 1 GB RAM, 10 GB free disk space for the data directory
- Fedora version confirmed: Run the command below to verify your release
cat /etc/fedora-release
Expected output:
Fedora release 43 (Forty Three)
If your system is running an older release, the steps in this guide still apply to Fedora 41 and 42, but the PostgreSQL version installed may differ.
Step 1: Update Your System Before Installation
Always update your system before installing new packages. This prevents dependency conflicts and makes sure you pull the latest security patches alongside your new software.
sudo dnf update -y
DNF5 in Fedora 43 handles this faster than older releases. You will see a progress bar as it resolves and downloads updates. Once the command finishes, reboot if the kernel was updated:
sudo reboot
After the system comes back up, you are ready to install PostgreSQL.
Step 2: Install PostgreSQL on Fedora 43 via the DNF Repository
This is the recommended method for most users. Fedora’s official repository carries PostgreSQL 18, which is the current default stream for Fedora 43.
Install both the server package and the contrib extensions package in one command:
sudo dnf install postgresql-server postgresql-contrib -y
What this installs:
postgresql-server: The PostgreSQL daemon, binaries, and default configuration filespostgresql-contrib: A collection of useful extensions includingpg_stat_statements,pgcrypto,tablefunc, anduuid-ossp
Verify the installation succeeded by checking the version:
psql --version
Expected output:
psql (PostgreSQL) 18.x
Why Install postgresql-contrib?
The postgresql-contrib package is not strictly required to run PostgreSQL, but it provides extensions that most real applications depend on. The pgcrypto extension handles password hashing inside the database. The pg_stat_statements extension tracks query performance, which you need for any serious tuning work. Install it now rather than tracking down a missing extension error later.
Step 3: Initialize the PostgreSQL Database Cluster
This step trips up a lot of people switching from Ubuntu or Debian, where PostgreSQL initializes automatically on install. On Fedora, you must run the initialization manually before the service will start.
sudo postgresql-setup --initdb --unit postgresql
What this command does:
- Creates the data directory at
/var/lib/pgsql/data/ - Generates the two main configuration files:
postgresql.confandpg_hba.conf - Creates the initial
postgresdatabase superuser role - Sets up the template databases (
template0andtemplate1)
Expected output:
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
If you see an error saying the directory already exists and is not empty, the cluster was already initialized. Skip this step and move to Step 4.
Step 4: Enable and Start the PostgreSQL Service
Now start the PostgreSQL service and configure it to start automatically on every boot:
sudo systemctl enable --now postgresql
The --now flag combines enable and start into one command. enable tells systemd to start PostgreSQL at boot. start brings it up immediately in the current session.
Verify the service is running:
sudo systemctl status postgresql
Look for this line in the output:
Active: active (running) since ...
Confirm PostgreSQL is listening on port 5432:
ss -tlnp | grep 5432
Expected output:
LISTEN 0 128 127.0.0.1:5432 0.0.0.0:*
At this point, PostgreSQL is installed and running. The next steps secure it and make it useful.
Step 5: Connect to PostgreSQL and Create a User and Database
By default, PostgreSQL on Fedora 43 uses peer authentication for local connections. This means the operating system username must match the PostgreSQL username. The postgres OS user was created automatically during installation.
Switch to the postgres user and open the PostgreSQL shell:
sudo -u postgres psql
You will see the psql prompt:
psql (18.x)
Type "help" for help.
postgres=#
Set a Password for the postgres Superuser
Before you do anything else, secure the postgres superuser account:
\password postgres
You will get an interactive prompt. Enter and confirm a strong password. This sets the database-level password for the postgres role, separate from the OS user account.
Create a New Database User and Database
CREATE USER myuser WITH PASSWORD 'strongpassword';
CREATE DATABASE mydb OWNER myuser;
Verify the user was created:
\du
Verify the database was created:
\l
Exit the psql shell:
\q
You can also create users and databases from the shell without entering psql at all. This is useful for scripting and automation:
sudo -u postgres createuser myuser
sudo -u postgres createdb mydb -O myuser
Step 6: Configure PostgreSQL on Fedora 43 for Remote Access
By default, PostgreSQL only accepts connections from localhost. To allow remote clients to connect, you need to edit two configuration files.
Both files live in the data directory:
/var/lib/pgsql/data/postgresql.conf/var/lib/pgsql/data/pg_hba.conf
Edit postgresql.conf
Open the file with any text editor:
sudo nano /var/lib/pgsql/data/postgresql.conf
Find the listen_addresses line and change it from:
#listen_addresses = 'localhost'
To:
listen_addresses = '*'
Setting listen_addresses = '*' tells PostgreSQL to accept connections on all network interfaces. For tighter control in production, replace '*' with your server’s specific IP address.
Key parameters worth reviewing in postgresql.conf:
| Parameter | Default | Recommended Action |
|---|---|---|
listen_addresses |
localhost |
Set to '*' for remote access |
port |
5432 |
Leave unless you have a conflict |
max_connections |
100 |
Increase for multi-user apps |
shared_buffers |
128MB |
Set to 25% of total RAM |
effective_cache_size |
4GB |
Set to 50% of total RAM |
Edit pg_hba.conf
The pg_hba.conf file controls which clients can connect and how they authenticate. Open it:
sudo nano /var/lib/pgsql/data/pg_hba.conf
To allow password-based connections from your local network, add this line:
host all all 192.168.1.0/24 md5
To allow password-based connections from localhost (required for most web applications), change the existing ident entries to md5:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Authentication method reference:
| Method | What It Does |
|---|---|
peer |
OS username must match DB username |
ident |
Ident server maps OS user to DB user |
md5 |
Requires a password hashed with MD5 |
trust |
No password needed (dev environments only) |
After editing both files, reload the service to apply the changes:
sudo systemctl reload postgresql
Step 7: Open the Firewall for PostgreSQL
Fedora 43 uses firewalld by default. PostgreSQL operates on port 5432. Open it permanently with:
sudo firewall-cmd --permanent --add-port=5432/tcp
sudo firewall-cmd --reload
Verify the port is open:
sudo firewall-cmd --list-ports
Expected output:
5432/tcp
Alternatively, use the named PostgreSQL service definition in firewalld:
sudo firewall-cmd --permanent --add-service=postgresql
sudo firewall-cmd --reload
Security note: Only open port 5432 to specific IP ranges in production. Never expose your database port to the entire internet without additional access controls.
Step 8: Handle SELinux on Fedora 43
Fedora 43 runs SELinux in Enforcing mode, which is a security feature, not a bug. For standard PostgreSQL installations using the default data directory, SELinux works without any extra configuration.
You only need to adjust SELinux when you do something non-default.
If you move the data directory to a custom path:
sudo semanage fcontext -a -t postgresql_db_t "/new/data/path(/.*)?"
sudo restorecon -Rv /new/data/path
If PostgreSQL needs to communicate with a web server (Apache or Nginx) over TCP:
sudo setsebool -P httpd_can_network_connect_db on
If you change PostgreSQL to a non-standard port (for example, 5433):
sudo semanage port -a -t postgresql_port_t -p tcp 5433
To check for SELinux denials related to PostgreSQL:
sudo ausearch -m avc -ts recent
Troubleshooting Common PostgreSQL Errors on Fedora 43
Error 1: FATAL: Ident authentication failed for user “myuser”
Cause: The pg_hba.conf file uses ident authentication for TCP connections, but your application is trying to connect with a username/password pair.
Fix: Open /var/lib/pgsql/data/pg_hba.conf and change ident to md5 on the 127.0.0.1/32 and ::1/128 lines. Then reload the service:
sudo systemctl reload postgresql
Error 2: Unit postgresql.service not found
Cause: The package is not installed, or you installed from the PGDG repository and the unit name is versioned.
Fix: Check what PostgreSQL packages are installed:
rpm -qa | grep ^postgres
If you installed postgresql17-server from PGDG, the service name is postgresql-17, not postgresql. Use:
sudo systemctl enable --now postgresql-17
Error 3: initdb: error: directory “/var/lib/pgsql/data” exists but is not empty
Cause: You ran --initdb on a data directory that is already initialized.
Fix: Skip the initialization step. The data directory is already set up. Go directly to:
sudo systemctl start postgresql
Error 4: could not connect to server: Connection refused (port 5432)
Cause: Either the service is not running or the firewall is blocking port 5432.
Fix: Check the service status first:
sudo systemctl status postgresql
Then verify the firewall:
sudo firewall-cmd --list-ports
If port 5432 is missing from the output, add it with the commands in Step 7.
Error 5: old cluster does not use data checksums but the new one does (Upgrade Error)
Cause: This appears when upgrading from PostgreSQL 16 to 18 on Fedora 43 because the new cluster uses data checksums by default and the old one does not.
Fix: Upgrade with checksums disabled, then enable them afterward:
PGSETUP_INITDB_OPTIONS="--no-data-checksums" postgresql-upgrade /var/lib/pgsql/data
Note that Fedora 43 jumped from PostgreSQL 16 to 18, skipping version 17. If you are upgrading from Fedora 42, you must upgrade in two steps: first to PostgreSQL 17, then to PostgreSQL 18. Database major version upgrades cannot skip a release.
Verify Your Full PostgreSQL Setup on Fedora 43
Run these four commands in order to confirm everything is working correctly:
# 1. Confirm service is active
sudo systemctl status postgresql
# 2. Confirm version
psql --version
# 3. Connect as postgres user
sudo -u postgres psql
# 4. Run a test query inside psql
SELECT version();
Expected output from SELECT version():
PostgreSQL 18.x on x86_64-redhat-linux-gnu, compiled by gcc ...
Exit psql with \q.
Congratulations! You have successfully installed PostgreSQL. Thanks for using this tutorial for installing PostgreSQL (RDBMS) on the Fedora 43 Linux system. For additional or useful information, we recommend you check the official PostgreSQL website.