PostgreSQL 58P01: undefined file
A file the server tried to open doesn't exist on the database server, typically COPY FROM a path that exists only on your machine, or a missing extension library.
- SQLSTATE
58P01- Name
undefined_file
What it means
58P01 (undefined_file) means PostgreSQL got "no such file" from the operating system. The important detail is where: server-side COPY ... FROM '/path', pg_read_file() and CREATE EXTENSION look on the database server's file system, not on the client running the query.
The other frequent case is a missing shared library, could not access file "$libdir/postgis-3": No such file or directory, after an upgrade or on a server where an extension's package isn't installed.
Common causes
COPY FROMwith a path on your laptop while the server runs on another machine or in a container.- A relative path, which the server resolves against its data directory.
- An extension's package isn't installed on the server, or is for a different major version after
pg_upgrade. shared_preload_librarieslists a library that isn't installed.
How to fix it
-
Load client-side files with psql's
\copy, which reads the file on the client and streams it to the server.\copy orders FROM 'orders.csv' WITH (FORMAT csv, HEADER true)
-
Or stream from the client with your driver's
COPY FROM STDINsupport. -
Install the extension's package for the server's major version (for example
postgresql-16-postgis-3), then create or update the extension.CREATE EXTENSION postgis; ALTER EXTENSION postgis UPDATE;
Related errors
The code and message text are from the PostgreSQL documentation, Appendix A: PostgreSQL Error Codes. Browse the full PostgreSQL error list or search every database error.
Work on PostgreSQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for PostgreSQL and the other databases you use.