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.
Seen on:
PHP
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026