SQLSTATE 58P03 ERROR Class 58: System Error

duplicate_file file name too long — 58P03

PostgreSQL error “file name too long — 58P03” (SQLSTATE 58P03): what it means, common causes, and how to fix it.

PG 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

PostgreSQL could not create or access a file because the path/name exceeded the operating system’s length limit. It reports SQLSTATE 58P03 (duplicate_file in this stub mapping; the OS error is “file name too long”).

  • A file path exceeded the OS name-length limit.
  • Often from a very long tablespace path or identifier.
  • An operating-system level filesystem error.

What the server log shows

ERROR:  could not create file "…very long path…": File name too long

Why PostgreSQL raises this — what the manual says

As Section 18.2 Creating a Database Cluster explains:

A path (such as the data-directory file or the Unix-domain socket directory) exceeded the operating system’s maximum filename length; relocate the cluster under a shorter data-directory path or configure a shorter socket directory.

Object files are placed under the data directory or a tablespace path. If the resulting path exceeds the filesystem’s maximum file-name length, the OS rejects the operation and PostgreSQL surfaces the filesystem error.

Common causes

  • An excessively long tablespace location path.
  • Very long object identifiers contributing to long paths.
  • A filesystem with a restrictive name-length limit.

How to fix it

  1. Use shorter tablespace paths/mount points.
  2. Avoid extremely long identifiers that inflate file paths.
  3. Place tablespaces on a filesystem with adequate path limits.

Related & next steps

Reference: PostgreSQL 18 Section 19.2 “Creating a Cluster”.

Was this helpful?