SQLSTATE 58P01 ERROR Class 58: System Error

undefined_file could not open file “…”: No such file or directory — 58P01

PostgreSQL error "could not open file "…": No such file or directory" (SQLSTATE 58P01): 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 tried to open a file it expected to exist (a relation segment, WAL file, or other server file) but the OS reported it missing. This raises SQLSTATE 58P01 (undefined_file).

  • A file the catalog references is absent on disk.
  • Can indicate corruption, manual file deletion, or restore problems.
  • The named path tells you what was expected.

What the server log shows

ERROR:  could not open file "base/16384/24576": No such file or directory

Why PostgreSQL raises this — what the manual says

Section 66.1 Database File Layout:

“Each table and index is stored in a separate file.”

System catalogs map relations to files on disk. When PostgreSQL needs a file that the catalog references but the OS cannot find it, it cannot read the data and reports 58P01.

Common causes

  • Files manually deleted/moved from the data directory.
  • An incomplete or inconsistent restore/copy.
  • Filesystem corruption or a missing tablespace mount.

How to fix it

  1. Ensure all tablespace mounts/paths are present and mounted.
  2. Never manually modify the data directory; restore from a consistent backup.
  3. Verify the restore copied every file; re-run from a known-good backup if not.

Related & next steps

Reference: PostgreSQL 18 Section 76.1 “Database File Layout”.

Was this helpful?