PostgreSQL Error 53100 Disk Full: How to Fix It
In this article
PostgreSQL error 53100 ("could not extend file" or "No space left on device") means the server ran out of free disk space before it could write to a table, index, or WAL file. You cannot clear it from SQL alone: you need to free space on the underlying filesystem, then verify that the database writes normally again. The steps below cover finding where the space went, reclaiming it safely, and preventing the problem from returning.
What You'll Need
- SSH or console access to the database server (or access to the host if PostgreSQL runs in Docker or a managed service)
- A PostgreSQL superuser account such as
postgres, plus a way to run commands as that OS user - Enough free space elsewhere (or a way to delete safely) to buy room for the database to breathe
- Access to the backups or snapshots, in case a cleanup goes wrong
A note on paths: log and data locations depend on your install and OS, so treat any path below as an example and confirm yours before deleting anything.
Step-by-Step
- Confirm it really is a disk-space error. Run
df -hto see filesystem usage anddf -ito check inode usage. A filesystem can show free kilobytes but still be out of inodes, which produces the same error. Locate your data directory withSHOW data_directory;in psql and confirm the mount that holds it. - Identify which directory is growing. Run
du -h -x --max-depth=1 /path/to/data | sort -h(adjust the path) and drill into the largest child. The usual culprits arebase/(table data and indexes),pg_wal/(write-ahead logs), and large log files. - Look for common space hogs inside the database. In psql, list the biggest relations with
SELECT relname, pg_size_pretty(pg_total_relation_size(oid)) FROM pg_class ORDER BY pg_total_relation_size(oid) DESC LIMIT 20;. Check for bloated tables, orphaned large objects, and old replicas of large tables. - Free emergency space first. Delete or rotate application and PostgreSQL log files (keep recent ones), remove old dump files sitting outside the data directory, and clear package caches. Never delete files directly from
base/orpg_wal/; PostgreSQL manages those, and removing them can corrupt or crash the cluster. - Handle write-ahead logs correctly. If
pg_walis huge, the cause is often archiving that cannot keep up, or a replica that has fallen behind. CheckSELECT * FROM pg_stat_archiver;and yourarchive_command. Do not just delete WAL files unless you have verified they are not needed for recovery or replication, and never on a server with no working backup. - Reclaim space from bloated tables with VACUUM. Run
VACUUM (VERBOSE) table_name;on heavily updated or deleted tables. For a table that has grown far beyond its useful size,VACUUM FULL table_name;rewrites it and returns space to the OS, but it takes an exclusive lock and needs temporary free space, so preferpg_repackwhere it is installed or run it during a maintenance window. - Drop genuinely unneeded data. Archive and then delete old rows in batches (for example, delete a few thousand at a time and commit between batches) instead of one huge DELETE. Drop unused indexes, old partitions, and stale staging tables after confirming with the application owner.
- Check for temporary files. Large sorts and hashes spill into the temporary tablespace. Look in
SELECT datname, temp_files, temp_bytes FROM pg_stat_database;and reduce the size of heavy queries or raise sensible work memory settings rather than letting sorts spill every time. - Restart PostgreSQL if it stopped accepting writes. Once space is available, restart the service with the platform's service manager (for example
sudo systemctl restart postgresql, or the equivalent for your OS or container setup). Then run a small test insert and aSELECTto confirm writes work. - Add capacity so it does not recur. Enlarge the volume, move the data directory to a larger mount, or split WAL and data onto separate volumes. Set up a free-space alert at a percentage threshold that gives you time to act.
Common Mistakes
Deleting files inside pg_wal or base. This is the fastest way to corrupt a cluster. Only PostgreSQL and its recovery tools should remove those files. Use pg_archivecleanup or proper archiving tools if you must prune WAL.
Running VACUUM FULL on a busy production table. It locks the table for writes and needs free space roughly equal to the table size. On a disk that is already full, it can fail or make things worse.
Thinking that DELETE frees disk space immediately. Deleted rows stay in the file as dead tuples until vacuuming reclaims them, and VACUUM by itself normally returns space inside the file rather than to the OS.
Ignoring inodes. A directory full of millions of tiny files shows plenty of free bytes but no free inodes. df -i catches this.
Clearing space without checking replication. Removing WAL that a standby still needs breaks replication and may force a rebuild of the replica.
Tips
Keep an eye on pg_wal and archive_status over the following days; a WAL directory that keeps growing after the fix usually points to a stalled archive command or a lagging replica. Make sure autovacuum is enabled and not blocked by long-running transactions, which prevent dead tuples from being cleaned up. Schedule periodic checks of the largest tables rather than waiting for an outage, and run a test restore of your backups so you know a cleanup is recoverable. Keep database logs on a separate volume where possible, so runaway logging does not fill the data disk.
Troubleshooting
The error persists after you have freed space. Confirm with df and df -i on the exact mount that holds the data directory, and check that the process you cleared is on the same host, filesystem, and container as the database. A deleted-but-still-open file (held by a process) shows as used space even though it is gone from the directory listing; restart the process holding it or find it in /proc.
The database will not start at all. A crash from a full disk can leave it in recovery. Start it, watch the log, and if the call stack reports a problem with a file, stop and restore from a backup rather than editing files by hand.
VACUUM keeps failing. It may need temporary space or be blocked by an old transaction. Query pg_stat_activity for long-running or idle-in-transaction sessions and end the ones that are safe to remove.
WAL grows again immediately. Verify that archiving is succeeding and that every replica is up to date. If WAL is filling because of replication, stop using a replica or reduce the replication lag before freeing space.
You are on a managed service. You may not have filesystem access. Use the provider's dashboard to check storage, increase the volume, and use its tools to rebuild or recreate the instance if it refuses to start. Do not attempt shell tricks on a managed platform.
If nothing works, restore the most recent backup onto a larger disk. That is slower but safer than chipping away at a failing cluster.
Frequently Asked Questions
What does PostgreSQL error 53100 mean exactly?
It is the SQLSTATE for a disk-full condition. PostgreSQL tried to extend a file but the operating system reported no more space, or it hit a file-system or inode limit.
Can I fix it by running VACUUM alone?
Not usually. VACUUM marks space reusable inside the table file but generally does not shrink the file on disk. You need to free space at the filesystem level, or use VACUUM FULL or pg_repack to rewrite tables on a volume that is not full.
Is it safe to delete files in pg_wal?
No. Those files are required for crash recovery and replication. Prune them only through PostgreSQL's own mechanisms after confirming they are not needed.
Will restarting PostgreSQL free the space?
It can release deleted files that a process was still holding open, which sometimes restores enough room to work with. It does not remove dead tuples or shrink tables.
Why is df showing free space but writes still fail?
Check inodes with df -i, confirm the data directory is on that same mount, and remember that a deleted-but-open file still occupies space until the holding process exits.
How do I prevent this happening again?
Alert on free space and inode usage at a threshold that gives you time to react, keep autovacuum healthy, add capacity before it is needed, and avoid writing logs to the data volume.