OSError: No Space Left on Device

OSError: [Errno 28] No space left on device

Quick Answer

The disk is full. Free up space by deleting temporary files or logs. Use log rotation to prevent unbounded growth.

Why This Happens

This error occurs when the filesystem has no free space. Common causes include large log files, temporary files not cleaned up, and Docker images filling the disk.

The Problem

with open('output.log', 'a') as f:
    while True:
        f.write('log entry\n')

The Fix

import logging
from logging.handlers import RotatingFileHandler
handler = RotatingFileHandler('output.log', maxBytes=10*1024*1024, backupCount=5)
logger = logging.getLogger()
logger.addHandler(handler)

Step-by-Step Fix

  1. 1

    Check disk usage

    Run df -h and du -sh /path/*.

  2. 2

    Clean up temp files

    Remove old logs and unused data.

  3. 3

    Implement log rotation

    Use RotatingFileHandler to prevent unbounded growth.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free