directory “…” does not exist

SQLSTATE 58P01 condition undefined_file class 58 — System Error (errors external to PostgreSQL itself) severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 9 Jun 2026 · Reproduced live with the SQL on this page.

Symptoms

A statement failed with SQLSTATE 58P01 (undefined_file), reported at severity ERROR. This is a System Error (errors external to PostgreSQL itself) condition: PostgreSQL emits the message directory "…" does not exist.

What the server log shows

ERROR:  directory "…" does not exist
HINT:  Create this directory for the tablespace before restarting the server.

Why PostgreSQL raises this

Class 58 (System Error) reports failures external to PostgreSQL itself — operating-system level I/O, file, or similar errors surfaced through the server.

As described in PostgreSQL’s Appendix A PostgreSQL Error Codes, SQLSTATE 58P01 carries the condition name undefined_file in class System Error (errors external to PostgreSQL itself). (Paraphrased — see the linked reference for the exact wording.)

Common causes

How to fix it

  1. Check OS logs, disk health, and filesystem permissions.
  2. Ensure the data directory is intact and writable.
  3. Address the underlying hardware/OS condition, then retry.

Version applicability

This message is present in PostgreSQL 15, 16, 17, 18 and 19.

Related & next steps

Reference: PostgreSQL Appendix A PostgreSQL Error Codes.