Skip to content

Disk Full

Error message

                could not extend file: No space left on device
              

Quick summary

The server's disk has run out of space — the database cannot write new data, WAL logs, or temporary files.

Why this happens

  • The disk is full due to data growth

  • Transaction logs (WAL) have grown too large

  • Temporary files from large sorts are filling the disk

  • Backups or log files are consuming disk space

Minimal example

✗ Broken code
# Disk is full — database cannot write
INSERT INTO logs (message) VALUES ('new event');
# → ERROR: could not extend file: No space left on device
✓ Fixed code
# Free up space first
df -h  # check disk usage
rm /var/log/app/old_logs/*.log  # remove old logs
# Now the insert can succeed
INSERT INTO logs (message) VALUES ('new event');

Freeing disk space (e.g., removing old log files) allows the database to write again.

How to diagnose

  • Check disk space: df -h

  • Check the size of the data directory and WAL logs

  • Identify large tables: SELECT pg_size_pretty(pg_total_relation_size('table'))

  • Check for old backups or log files that can be cleaned up

How to fix

  • Free up disk space — remove old backups, logs, and temporary files

  • Increase the disk size

  • Archive or partition old data to a separate storage

  • Clean up WAL logs or adjust retention settings

How to prevent

  • Monitor disk usage and alert before it reaches 80-90%

  • Set up automated log rotation and backup retention policies

  • Use table partitioning to manage large datasets

  • Plan capacity based on data growth projections

Related Resources

Related Glossary

Related Lessons

← Back to language