Managing the PostgreSQL service with systemctl is the control point for reloading authentication changes, restarting after server-level settings, stopping the database for maintenance, and checking whether the server is actually running.
On systemd based Linux hosts, PostgreSQL may appear as one service unit or as an umbrella unit plus versioned cluster units. Debian and Ubuntu commonly show postgresql.service as the umbrella service and units such as postgresql@18-main.service for the running cluster.
Use the unit names from the local host before restarting anything. The sample output uses the Debian and Ubuntu cluster layout; replace postgresql@18-main.service with the running unit shown by systemctl list-units, or use postgresql when the distribution exposes only one service unit.
Related: How to configure pg_hba.conf in PostgreSQL
Related: How to upgrade PostgreSQL safely
$ systemctl list-unit-files --type=service 'postgresql*' UNIT FILE STATE PRESET postgresql.service enabled enabled postgresql@.service indirect enabled 2 unit files listed.
postgresql@.service is a template. Actual cluster units include the version and cluster name, such as postgresql@18-main.service.
$ systemctl list-units --type=service 'postgresql*' UNIT LOAD ACTIVE SUB DESCRIPTION postgresql.service loaded active exited PostgreSQL RDBMS postgresql@18-main.service loaded active running PostgreSQL Cluster 18-main ##### snipped #####
On Debian and Ubuntu, active exited on postgresql.service means the umbrella service is active; the versioned cluster unit is the database process to inspect for runtime state.
$ sudo systemctl status postgresql@18-main.service --no-pager
● postgresql@18-main.service - PostgreSQL Cluster 18-main
Loaded: loaded (/usr/lib/systemd/system/postgresql@.service; enabled-runtime; preset: enabled)
Active: active (running) since Sun 2026-06-07 05:06:36 UTC; 53s ago
Process: 65 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 18-main start (code=exited, status=0/SUCCESS)
Main PID: 83 (postgres)
##### snipped #####
Jun 07 05:06:33 postgresql-demo systemd[1]: Starting postgresql@18-main.service - PostgreSQL Cluster 18-main...
Jun 07 05:06:36 postgresql-demo systemd[1]: Started postgresql@18-main.service - PostgreSQL Cluster 18-main.
Use sudo systemctl status postgresql on systems where the discovered service list shows only postgresql.service.
$ sudo systemctl reload postgresql
Reloading asks the server to reread reloadable configuration files. Parameters marked as requiring server start still need a restart.
$ sudo systemctl restart postgresql
A restart disconnects active sessions and can abort in-flight transactions.
$ systemctl is-active postgresql@18-main.service active
$ sudo -u postgres pg_isready /var/run/postgresql:5432 - accepting connections
$ sudo systemctl stop postgresql
Stopping PostgreSQL makes local and remote database connections fail until the service is started again.
$ sudo systemctl start postgresql
$ sudo systemctl disable --now postgresql Synchronizing state of postgresql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install disable postgresql Removed '/etc/systemd/system/multi-user.target.wants/postgresql.service'.
Omit --now when the service should keep running until the next reboot.
$ sudo systemctl enable --now postgresql Synchronizing state of postgresql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable postgresql Created symlink '/etc/systemd/system/multi-user.target.wants/postgresql.service' → '/usr/lib/systemd/system/postgresql.service'.
$ sudo journalctl --unit=postgresql@18-main.service --no-pager ##### snipped ##### Jun 07 05:07:32 postgresql-demo systemd[1]: Stopping postgresql@18-main.service - PostgreSQL Cluster 18-main... Jun 07 05:07:32 postgresql-demo systemd[1]: postgresql@18-main.service: Deactivated successfully. Jun 07 05:07:32 postgresql-demo systemd[1]: Stopped postgresql@18-main.service - PostgreSQL Cluster 18-main. Jun 07 05:07:32 postgresql-demo systemd[1]: Starting postgresql@18-main.service - PostgreSQL Cluster 18-main... Jun 07 05:07:35 postgresql-demo systemd[1]: Started postgresql@18-main.service - PostgreSQL Cluster 18-main.
Use the unit that failed in the previous step. For an umbrella-only service, use --unit=postgresql.service.