Warning: session_start(): open(/var/lib/php/sessions/sess_x, O_RDWR) failed: Permission denied
PHP can’t write session files to the configured session.save_path.
session_start(): open(failed: Permission denied (13)Failed to write session data Meaning
The session directory must be writable by the PHP process user. After changing the PHP-FPM user, restoring from backup or using a custom save path, permissions often don’t match.
Common causes
- save_path owned by another user
- Directory doesn’t exist
- Disk full
- SELinux context blocking writes
⚡ Quick fix
- Check
session.save_pathin phpinfo() - Make the directory writable by the PHP user
- Use a path inside your app (e.g. storage/sessions) or a Redis session handler
Detailed fix by platform
Linux
sudo chown -R www-data:www-data /var/lib/php/sessions && sudo chmod 1733 /var/lib/php/sessions
How to diagnose
- Path — Which save path?
- Owner — Who owns it vs which user runs PHP?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026