directory “…” does not exist
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.
- The client receives SQLSTATE
58P01(undefined file). - The operation is rejected at
ERRORlevel; the statement does not complete.
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
- An underlying file/IO operation failed at the OS level.
- Disk, permissions, or hardware problems on the data directory.
- A duplicate or missing file detected by the server.
How to fix it
- Check OS logs, disk health, and filesystem permissions.
- Ensure the data directory is intact and writable.
- 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.