Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Fixing "No Space Left on Device (28)" & Session Write Errors in PHP

2 min read
24.04.2026
Fix No Space Left on Device (28) Session Write Errors PHP
errno 28 — disk full or inodes exhausted; session can't write.

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
Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

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!

Frequently asked questions
Almost always inodes. Run `df -i`. Filesystems have a fixed number of inodes (one per file/dir). When you have many tiny session files in `/var/lib/php/sessions`, inodes run out long before bytes. Clean up old session files (find -mtime +1 -delete) and consider Redis/Memcached for sessions to avoid the issue.
Yes — if session.save_path is on /tmp and /tmp has its own small partition, /tmp fills before /var/. `df -h /tmp` to see. Fix by moving session.save_path to /var/lib/php/sessions (often more space), or expanding /tmp.
session.gc_maxlifetime + session.gc_probability/divisor. Default cleanup is probabilistic — every request has 1/100 chance to garbage-collect. On low-traffic sites old sessions accumulate. Either: lower divisor (more aggressive) or run a daily cron: `find /var/lib/php/sessions -name 'sess_*' -mtime +1 -delete`.
Move sessions out of the filesystem. Set `session.save_handler = redis` with `session.save_path = "tcp://127.0.0.1:6379"`. Or Memcached. Zero file-management, zero inode pressure, faster on high-traffic. For multi-server deploys, also required — file-based sessions don't work across servers.
Related articles
Fixing session_start() failed: Permission denied (13) — A System Administrator's Guide
Fixing phpMyAdmin "Error During Session Start" — Complete Guide
Debugging session_start() Errors in PHP Using Error Logs