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
- Ensure the data directory is owned by the postgres OS user with proper permissions (typically 0700).
- Fix tablespace directory ownership/permissions.
- Check SELinux/AppArmor contexts and that the filesystem is writable.
Related & next steps
Reference: PostgreSQL 18 Section 19.2 “Creating a Cluster”.
Thanks — noted. This helps keep the database accurate.