Error
Error Code:
53100
PostgreSQL Error 53100: Insufficient Disk Space
Description
This error indicates that the PostgreSQL database server or the underlying operating system has run out of available disk space. It typically occurs when the system attempts to write data, logs, or temporary files but cannot allocate the necessary storage.
Error Message
disk full
Known Causes
3 known causesDatabase Data & WAL Growth
The primary PostgreSQL data directory, including tables, indexes, and Write-Ahead Log (WAL) files, has expanded beyond the available disk capacity.
Operating System Disk Consumption
Other applications, system files, or user data on the same storage volume as PostgreSQL have consumed critical disk space.
Excessive Log File Accumulation
PostgreSQL transaction logs, server logs, or operating system logs are configured to retain too much data, leading to a build-up that exhausts disk space.
Solutions
4 solutions available1. Free Disk Space easy
Remove unnecessary files to free space
1
Check disk usage
df -h
2
Find large files
du -sh /var/lib/postgresql/*
du -sh /var/log/*
3
Clear old WAL files (if not needed)
-- Check archive status first
SELECT * FROM pg_stat_archiver;
4
Clean old logs
sudo find /var/log/postgresql -name '*.log' -mtime +30 -delete
2. Vacuum Database medium
Reclaim space from dead tuples
1
Run VACUUM
VACUUM FULL your_table; -- Reclaims space (locks table)
-- Or
VACUUM your_table; -- Less aggressive, no lock
2
Vacuum entire database
vacuumdb -U postgres -d your_database -f
3. Add More Disk Space medium
Expand storage capacity
1
Add disk space to server
# Cloud: Expand volume size
# On-prem: Add disk and expand LVM
2
Move tablespace to new disk
CREATE TABLESPACE new_space LOCATION '/mnt/new_disk/pg_data';
ALTER TABLE big_table SET TABLESPACE new_space;
4. Archive Old Data medium
Move historical data to separate storage
1
Create archive table
CREATE TABLE logs_archive (LIKE logs INCLUDING ALL);
2
Move old data
INSERT INTO logs_archive SELECT * FROM logs WHERE created_at < '2023-01-01';
DELETE FROM logs WHERE created_at < '2023-01-01';
VACUUM logs;