SQLSTATE 58030 ERROR Class 58: System Error

io_error could not create file “…”: Permission denied — 58030

PostgreSQL error "could not create file "…": Permission denied" (SQLSTATE 58030): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

PostgreSQL could not create a file because the operating system denied permission. PostgreSQL raises SQLSTATE 58030 (io_error).

  • The OS rejected file creation in the data directory or tablespace.
  • Often a filesystem permission/ownership problem.
  • May follow a botched manual change to data-dir permissions.

What the server log shows

ERROR:  could not create file "base/16384/t3_24576": Permission denied

Why PostgreSQL raises this — what the manual says

Section 18.2 Creating a Database Cluster:

“Of course, this will fail if initdb does not have permissions to write in the parent directory.”

The PostgreSQL server process must own and be able to write the data directory and tablespaces. If the OS denies file creation, PostgreSQL cannot proceed and reports 58030.

Common causes

  • Wrong ownership/permissions on the data directory or a tablespace path.
  • A tablespace pointing at a directory the server can’t write.
  • SELinux/AppArmor or a read-only filesystem blocking writes.

How to fix it

  1. Ensure the data directory is owned by the postgres OS user with proper permissions (typically 0700).
  2. Fix tablespace directory ownership/permissions.
  3. Check SELinux/AppArmor contexts and that the filesystem is writable.

Related & next steps

Reference: PostgreSQL 18 Section 19.2 “Creating a Cluster”.

Was this helpful?