// PostgreSQL error reference

PostgreSQL 53100: disk full

The file system holding the data directory, WAL or temporary files is full. Writes fail until space is freed; a full WAL disk can stop the server.

SQLSTATE
53100
Name
disk_full
Category
Insufficient Resources
Error message
could not extend file "base/16384/16397": No space left on device
HINT:  Check free disk space.

What it means

PostgreSQL got No space left on device from the operating system while growing a table or index file, writing temporary sort files, or writing WAL. The statement fails with 53100 (disk_full) and its transaction is rolled back.

If the WAL directory (pg_wal) fills up, the server can't write any changes and shuts down with a PANIC; it won't start again until space is freed. Never delete files from pg_wal by hand.

Common causes

  • Data growth, or table and index bloat from heavy updates and deletes without enough vacuuming.
  • WAL piling up because a replication slot is inactive, archiving (archive_command) is failing, or max_wal_size / wal_keep_size are large.
  • A large sort, hash or CREATE INDEX writing temporary files.
  • Server logs or other files on the same volume.

How to fix it

  1. Find what is using the space.

    SELECT pg_size_pretty(pg_database_size(current_database()));
    SELECT relname, pg_size_pretty(pg_total_relation_size(oid)) AS size
    FROM pg_class WHERE relkind = 'r'
    ORDER BY pg_total_relation_size(oid) DESC LIMIT 10;
  2. Look for replication slots holding WAL back, and drop the ones no longer used.

    SELECT slot_name, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained
    FROM pg_replication_slots;
    SELECT pg_drop_replication_slot('old_slot');
  3. Check that WAL archiving succeeds.

    SELECT archived_count, failed_count, last_failed_wal, last_failed_time FROM pg_stat_archiver;
  4. Free or add disk space: grow the volume, remove unrelated files, or reclaim bloat with VACUUM FULL (which needs room for a full copy of the table) or pg_repack.

  5. Limit temporary file use per session so one query can't fill the disk.

    ALTER SYSTEM SET temp_file_limit = '20GB';
    SELECT pg_reload_conf();

Related errors

More insufficient resources 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.

// fewer errors, faster fixes

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.