8. Verify and troubleshoot
8.1 Health checks after install
Section titled “8.1 Health checks after install”On suta-linux-lab-1, as student:
# 1a. Is the service running now?systemctl is-active postgresql-18Expected output:
active# 1b. Will it start at boot?systemctl is-enabled postgresql-18Expected output:
enabledis-activeandis-enabledprint one word each, so they are quicker to read thanstatus.
# 2. Is the server accepting connections?/usr/pgsql-18/bin/pg_isreadypg_isreadyasks the server "can you accept a connection?" without logging in.
Expected output:
/run/postgresql:5432 - accepting connections# Switch to the postgres user (type exit to come back)sudo su - postgresThe next two checks are SQL, run with psql -c as in 5.2. Now as postgres on
suta-linux-lab-1:
# 3. Which exact version is running?psql -c 'SELECT version();'Expected output:
version----------------------------------------------------------------------------------------------------------- PostgreSQL 18.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-17), 64-bit(1 row)# 4. Are data checksums on? (new default in 18)psql -c 'SHOW data_checksums;'Expected output:
data_checksums---------------- on(1 row)# Return to the student userexit8.2 The six most common errors
Section titled “8.2 The six most common errors”Every message below was produced on a real CentOS Stream 9 server with PostgreSQL 18.7.
| # | You see | Cause | Fix |
|---|---|---|---|
| 1 | Failed to download metadata for repo 'pgdg-common' |
CentOS Stream has no minor version for the PGDG repo address | Do the CentOS Stream step in 4.1 |
| 2 | initdb: error: cannot be run as root |
You ran initdb as root |
Use the setup script, or run initdb as postgres |
| 3 | initdb: error: directory "/var/lib/pgsql/18/data" exists but is not empty |
The cluster already exists | Nothing to do. Never empty this folder on a real server |
| 4 | Job for postgresql-18.service failed |
A typo in postgresql.conf |
Run sudo journalctl -u postgresql-18 --no-pager -n 20 (-n 20 shows the last 20 lines), read the LOG: line, fix that setting |
| 5 | FATAL: role "student" does not exist |
psql used your Linux name as the role | sudo su - postgres first, or psql -U with a real role |
| 6 | Connection refused, No route to host, timed out or no pg_hba.conf entry |
One of the remote gates is closed | Use the diagram in 7.2: refused = service or listen_addresses, no route = firewalld, timed out = AWS security group, no entry = pg_hba.conf |
Error 4 in real life. A setting was typed with the letter O instead of zero (1OO):
LOG: invalid value for parameter "max_connections": "1OO"FATAL: configuration file "/var/lib/pgsql/18/data/postgresql.conf" contains errorsThe LOG: line names the exact setting. Read it before changing anything else.
Was this page helpful?
Thanks. Glad it helped.
Thanks for telling us. Email the instructor what was missing, or ask in class.