Session_write_close(): Failed to write session data (files)

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.4.1
  • Operating system and version (e.g., Ubuntu 24.04):
    • armbian
  • Web server and version (e.g, Apache 2.4.25):
    • apache 2.4.62
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • replace me
  • PHP version (e.g, 8.3):
    • 8.2.28
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • Today,
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • don’t remember but many web updates since installation.
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • don’t know. I will look for if it is a usefull info.

Summary of the issue you are facing:

I tried to log in with the web interface. I doesn’t work but I don’t see any error message (like wrong password for example).
I changed the password with the command line to be sure. The behaviour is the same.

I don’t use the web interface that much so it could be the first time after the upgrade to the current version.

Here are the permissions for the session directory (see log entry) :

drwx-wx-wt  2 root root 28672 10 mai   12:28 sessions

To me this directory is writable to any user.
What can it be?

Thanks
Julien

Log entries

Nextcloud


{
"reqId":"XCXp5pAp806tGduFgTvR",
"level":3,"time":"2025-05-10T10:12:31+00:00",
"remoteAddr":"<snip>",
"user":false,"app":"PHP",
"method":"GET",
"url":"/index.php/login?user=<snip>&direct=1",
"message":"session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) at /var/www/nextcloud/lib/private/Session/Internal.php#198",
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
"version":"31.0.4.1",
"data":{"app":"PHP"}
}

I think group ownership needs to be the web server.

chown root:www-data /var/lib/php/sessions

Thanks for your answer.

drwx-wx-wt  2 root root 28672 10 mai   12:28 sessions

As far as I remember my Linux course, permissions are the same for group and ‘others’ are the same in this case. Please, can you elaborate?

With root:root ownership the web server user for PHP can’t write to the session directory. I don’t use Debian or derivatives but I’m fairly certain root:{webservergroup} with permission 770 is enough to make it work.

Since armbian is derived from Debian and Ubuntu I assumed its default web server user and group are named www-data. The main Apache config should have User and Group lines that tell you.

ok, I finally found another interesting log :

"message":"session_write_close(): Write failed: No space left on device (28) at /var/www/nextcloud/lib/private/Session/Internal.php#198",

Kind of obvious…