🔧 Error Fixes
· 1 min read

Python OSError: [Errno 28] No Space Left on Device — How to Fix It


OSError: [Errno 28] No space left on device

Your disk is full. Python can’t write files, create temp files, or save data.

Fix 1: Check disk space

df -h

Look for filesystems at 100% usage.

Fix 2: Clean up common space hogs

# Docker images and containers
docker system prune -a

# pip cache
pip cache purge

# npm cache
npm cache clean --force

# Old log files
sudo journalctl --vacuum-size=100M

# Temp files
sudo rm -rf /tmp/*

Fix 3: Find large files

# Find files over 100MB
find / -type f -size +100M 2>/dev/null | head -20

# Check directory sizes
du -sh /* 2>/dev/null | sort -rh | head -10

Fix 4: Write to a different location

import tempfile

# ✅ Use a different temp directory
with tempfile.NamedTemporaryFile(dir='/path/with/space') as f:
    f.write(data)
📘