session save path PHP Origin: Application & API OSI layer 5 · Session Last updated 14 Oct 2026

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.

Exact message you may see session_start(): open(failed: Permission denied (13)Failed to write session data
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

  1. Check session.save_path in phpinfo()
  2. Make the directory writable by the PHP user
  3. Use a path inside your app (e.g. storage/sessions) or a Redis session handler

Detailed fix by platform

Linux

  1. sudo chown -R www-data:www-data /var/lib/php/sessions && sudo chmod 1733 /var/lib/php/sessions

How to diagnose

  1. Path — Which save path?
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

229 — SQL Server Msg 229: The SELECT permission was denied on the object (SQL)229401 — HTTP 401 Unauthorized (HTTP)401403 — HTTP 403 Forbidden (HTTP)4035123 — SQL Server Msg 5123: CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open the physical file (SQL)5123916 — SQL Server Msg 916: The server principal is not able to access the database under the current security context (SQL)916AADSTS65001 — AADSTS65001: The user or administrator has not consented to use the application (Azure)AADSTS65001Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…AccessControlListNotSupported — AccessControlListNotSupported: The bucket does not allow ACLs (AWS)AccessControlListNotS…session s…

Explore the map of this error Full error map →

🧠 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.