Fixing "No Space Left on Device (28)" & Session Write Errors in PHP
24.04.2026
For other PHP-session errors, see Fixing session_start() failed: Permission denied (13).
Check Disk Space
Run the following command:
df -h
If /var or /tmp is 100% full, free up space by deleting unnecessary files:
sudo rm -rf /var/log/*.gz
sudo rm -rf /var/tmp/*
sudo rm -rf /tmp/*
After freeing space, restart Apache or Nginx:
sudo systemctl restart apache2
or
sudo systemctl restart nginx
Check Inodes (If Disk Space is Available)
Even if disk space is not full, inodes might be exhausted.
Check inode usage:
df -i
If inodes are full (e.g., 100% usage), clear unused session files:
sudo rm -rf /var/lib/php/sessions/*
Restart PHP & Web Server
sudo systemctl restart php8.0-fpm
sudo systemctl restart apache2
Verify session.save_path in php.ini
If the error persists, check the session storage path.
Locate php.ini
Find your active PHP configuration:
php --ini | grep "Loaded Configuration File"
Edit the file:
sudo nano /etc/php/8.0/apache2/php.ini
or for PHP-FPM:
sudo nano /etc/php/8.0/fpm/php.ini
Update Session Settings
Find:
session.save_path = "/var/lib/php/sessions"
If /var/lib/php/sessions is full or restricted, use /tmp/php_sessions instead:
session.save_path = "/tmp/php_sessions"
Save & Restart Services
sudo systemctl restart php8.0-fpm
sudo systemctl restart apache2
Check Permissions on the Session Directory
Ensure PHP can write to the session folder:
sudo chmod -R 770 /var/lib/php/sessions
sudo chown -R www-data:www-data /var/lib/php/sessions # For Apache
sudo chown -R nginx:nginx /var/lib/php/sessions # For Nginx
Summary of Fixes
| Issue | Fix |
|---|---|
| Disk space full | Run df -h and delete unnecessary files |
| Inodes full | Run df -i and delete session files |
| Wrong session.save_path | Change it to /tmp/php_sessions in php.ini |
| Permissions issue | Set chmod -R 770 /var/lib/php/sessions |
Now PHP sessions should work properly!


