data directory permissions 🐘 PostgreSQL

FATAL: data directory "/var/lib/postgresql/data" has invalid permissions — Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).

PostgreSQL refuses to start because the data directory is too open or owned by the wrong user.

Seen on: PostgreSQL

Meaning

Common with Docker bind mounts on Windows/macOS or after copying data with root.

Common causes

  • Bind mount with wrong ownership/permissions (Docker on Windows/macOS)
  • Data copied as root
  • chmod -R 777 applied

⚡ Quick fix

  1. chown -R postgres:postgres and chmod 700 the data directory
  2. Use a named Docker volume instead of a host bind mount

Detailed fix by platform

Docker

  1. volumes: [pgdata:/var/lib/postgresql/data] # named volume

How to diagnose

  1. Owner — ls -ld data dir
  2. Mode — 0700?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.