SQLSTATE 53100 ERROR Class 53: Insufficient Resources

disk_full could not write to file “…”: No space left on device — 53100

PostgreSQL error "could not write to file "…": No space left on device" (SQLSTATE 53100): 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 could not write to a file (often a temporary or WAL file) because the device is full. It raises SQLSTATE 53100 (disk_full).

  • Common with large sorts/hash joins writing temp files.
  • Also seen when the WAL/pg_wal directory volume fills.
  • The named file indicates whether it is temp, WAL, or relation data.

What the server log shows

ERROR:  could not write to file "base/pgsql_tmp/pgsql_tmp12345.0": No space left on device

Why PostgreSQL raises this — what the manual says

Section 19.4.2 Disk (temp_file_limit):

“Specifies the maximum amount of disk space that a process can use for temporary files, such as sort and hash temporary files, or the storage file for a held cursor.”

Operations that exceed memory spill to temporary files; WAL and relations also write to disk. When the volume is full, the OS write fails and PostgreSQL reports 53100, cancelling the operation.

Common causes

  • Huge sorts/hash joins spilling large temp files.
  • The temp tablespace volume running out of space.
  • WAL accumulation filling pg_wal.

How to fix it

  1. Cap per-process temp usage with temp_file_limit.
  2. Reduce data scanned/sorted; add indexes or paginate.
  3. Move temp files to a larger tablespace, or expand the volume.

Related & next steps

Reference: PostgreSQL 18 Section 19.4 “Resource Consumption”.

Was this helpful?