Fix PostgreSQL that will not start

We'll check systemctl status, journalctl, pg_log, config and permissions, disk space, and port conflicts—or tell you when to escalate.

Category
Troubleshooting · Servers & Linux
Time
15–30 min
Last reviewed
What you'll need
  • SSH or console access with sudo
  • Access to the PostgreSQL data directory

Step-by-step diagnostic

Step 1 of 6
Show full guide

Steps

Goal: Confirm the problem, read systemctl status, journalctl, and pg_log, then fix config, permissions, disk, or port.

  • Run systemctl status postgresql to see the current state.
  • Good: You see failed or inactive with an error hint. Proceed to Check status and logs.
  • Bad: Status shows active—PostgreSQL is running; see fix-database-will-not-connect for connection issues.

Check status and logs

Goal: Read systemd status and journalctl to identify the error.

  • Run systemctl status postgresql and note the error line.
  • Run journalctl -u postgresql -n 50 --no-pager to read recent logs.
  • Good: You see permission denied, config error, address in use, or disk full. Proceed to Check pg_log.
  • Bad: Unclear—check pg_log next.

Check pg_log

Goal: Read pg_log for the exact failure reason.

  • Check /var/log/postgresql/ (e.g. postgresql-14-main.log) or the log folder in the data directory.
  • Read the last 20–50 lines. PostgreSQL writes the failure reason before exiting.
  • Good: You see the error (e.g. “permission denied”, “could not create lock file”, “data directory has wrong ownership”). Proceed to Fix config or permissions.
  • Bad: Corruption or recovery needed—escalate.

Fix config or permissions

Goal: Fix the cause identified from the logs.

  • Permission denied: Run sudo chown -R postgres:postgres on the data directory.
  • Config error: Validate with postgres --check -D /path/to/data. Fix postgresql.conf or pg_hba.conf.
  • Disk full: Run df -h, free space on the partition with the data directory.
  • Port 5432 in use: Run ss -tlnp | grep 5432, stop the conflicting process or change the port in postgresql.conf.
  • Run sudo systemctl start postgresql. Confirm you should see active (running).

When to escalate

When to get help: If the data directory is corrupted or recovery is needed, call a professional—do not attempt recovery yourself. When you suspect hardware failure or need recovery from backup, contact your database vendor or a DBA.

Provide systemctl status, journalctl -u postgresql, and pg_log.

Verification

  • systemctl status postgresql shows active (running).
  • psql -U postgres -h localhost connects from the server.
  • No errors in pg_log after startup.

Escalation ladder

Work from the device outward. Stop when the problem is fixed.

  1. Status and journalctl systemctl status postgresql; journalctl -u postgresql -n 50.
  2. pg_log Check /var/log/postgresql/ or $PGDATA/log.
  3. Config, permissions, disk, port postgres --check; chown data dir; df -h; ss -tlnp | grep 5432.
  4. Escalate Provide status, journalctl, and pg_log.

What to capture if you need help

Before calling support or posting for help, have these ready. It speeds everything up.

  • systemctl status postgresql output
  • journalctl -u postgresql -n 100 output
  • pg_log (last 50 lines)
  • Steps already tried

What does systemctl status postgresql show?

Run systemctl status postgresql to see the state and error.

Run `systemctl status postgresql`. Failed or inactive: read the status output, then run `journalctl -u postgresql -n 50`. Active: PostgreSQL is running—different issue (e.g. connection). Good: you see the error. Bad: status unclear—check pg_log.

You can change your answer later.

PostgreSQL is running

If systemctl status shows active (running), PostgreSQL started. If you have connection issues, see fix-database-will-not-connect.

What does journalctl -u postgresql show?

Read systemd logs for the postgresql service.

Run `journalctl -u postgresql -n 50 --no-pager`. Look for permission denied, config error, address already in use, disk full. Permission denied: check chown on the data directory. Address in use: ss -tlnp | grep 5432. Disk full: df -h. Other: check pg_log.
Question

What does journalctl show?

You can change your answer later.

What does pg_log show?

Check /var/log/postgresql/ or $PGDATA/log.

Check pg_log in /var/log/postgresql/ or the data directory log folder. Read the last 20–50 lines. Permission denied / wrong ownership: chown -R postgres:postgres on the data directory. Corruption: may need recovery—escalate. Config error: fix postgresql.conf or pg_hba.conf. Port in use: stop the conflicting process or change port. Good: you identify the cause. Bad: escalate with the log.

You can change your answer later.

Apply the fix

Fix config, permissions, disk space, or port conflict. Run `sudo systemctl daemon-reload` if you edited a unit file. Run `sudo systemctl start postgresql`. Confirm you should see active (running).

Escalate

Escalate if the data directory is corrupted, you suspect hardware failure, or recovery from backup is needed. Provide systemctl status, journalctl -u postgresql, and pg_log.

Reviewed by Blackbox Atlas

Frequently asked questions

Why would PostgreSQL not start?
Config error, permission denied on the data directory, disk full, port 5432 already in use, or corrupted data files. Check systemctl status, journalctl -u postgresql, and pg_log.
Can I fix PostgreSQL that will not start myself?
Yes. Read pg_log, fix config syntax, check permissions on the data directory, confirm disk space, and resolve port conflicts. Run postgres --check to validate config.
When should I escalate PostgreSQL start failures?
If the data directory is corrupted, you suspect hardware failure, or the fix requires recovery from backup. Provide systemctl status, journalctl output, and pg_log.

Rate this guide

Was this helpful?

Thanks for your feedback.

Continue to