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.
What you'll need
- SSH or console access with sudo
- Access to the PostgreSQL data directory
Step-by-step diagnostic
Quick triage — pick your path
Quick triage — pick your path
Choose the option that matches what you see. You can jump straight to that section.
- Follow this guide Work through the full procedure from status to pg_log.
- Check status and logs You want to see the error first.
- Check pg_log You need the PostgreSQL-specific error.
- Fix config or permissions You know the config or permissions are wrong.
- When to escalate Data corruption or recovery needed.
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 postgresqlto 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 postgresqland note the error line. - Run
journalctl -u postgresql -n 50 --no-pagerto 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:postgreson 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 postgresqlshows active (running).psql -U postgres -h localhostconnects from the server.- No errors in pg_log after startup.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Status and journalctl systemctl status postgresql; journalctl -u postgresql -n 50.
- pg_log Check /var/log/postgresql/ or $PGDATA/log.
- Config, permissions, disk, port postgres --check; chown data dir; df -h; ss -tlnp | grep 5432.
- 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.
You can change your answer later.
PostgreSQL is running
What does journalctl -u postgresql show?
Read systemd logs for the postgresql service.
What does journalctl show?
You can change your answer later.
What does pg_log show?
Check /var/log/postgresql/ or $PGDATA/log.
You can change your answer later.
Apply the fix
Escalate
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.