[Solved] Error: Exception: Session has been closed - no further changes to the session are allowed

Nextcloud version : 15.0.4
Operating system and version : Debian 9.8
Apache or nginx version : Apache 2.4.25-3
PHP version : 7.0.33

The issue I was facing:
Every 15 minutes an error shows op in my error log. Unfortunately, I don´t know where this one is comming from. Would any of you know how to resolve this one or could give me tips where to look?

Is this the first time you’ve seen this error? : Yes

Steps to replicate it:

  1. Nothing, the error shows up every 15 minutes.

The output of your Nextcloud log in Admin > Logging:

    /var/www/html/nextcloud/lib/private/Session/Memory.php - line 81:
    /var/www/html/nextcloud/apps/encryption/lib/Session.php - line 179:
    /var/www/html/nextcloud/apps/encryption/lib/Hooks/UserHooks.php - line 190:
    /var/www/html/nextcloud/lib/private/legacy/hook.php - line 106:
    /var/www/html/nextcloud/lib/private/Server.php - line 425:
    OC_Hook::emit("OC_User", "logout", [])
    OC\Server->OC\{closure}("*** sensiti ... *")
    /var/www/html/nextcloud/lib/private/Hooks/EmitterTrait.php - line 99:
    call_user_func_array(Closure {}, [])
    /var/www/html/nextcloud/lib/private/Hooks/PublicEmitter.php - line 36:
    OC\Hooks\BasicEmitter->emit("\\OC\\User", "logout", [])
    /var/www/html/nextcloud/lib/private/User/Session.php - line 863:
    OC\Hooks\PublicEmitter->emit("\\OC\\User", "logout")
    /var/www/html/nextcloud/apps/bookmarks/lib/BackgroundJobs/PreviewsJob.php - line 51:
    /var/www/html/nextcloud/lib/private/BackgroundJob/Job.php - line 61:
    /var/www/html/nextcloud/lib/private/BackgroundJob/TimedJob.php - line 55:
    OC\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
    /var/www/html/nextcloud/cron.php - line 123:
    OC\BackgroundJob\TimedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

Thank You!

After a long break, I had some time to finally tackle this problem. Looking back at my log I saw a mention of the Bookmarks app. After disabling this app, the error in the log was gone.

The error comes from a (your?) cronjob that starts every 15 min. So you should check your cronjobs.

Thank you for your answer. I looked into my list of cronjobs (crontab -l) but did not find a job running every 15 minutes. I only have one job that runs weekly in order to renew my LE certificate.

It’s probably a cronjob of the user www-data:

sudo -u www-data crontab -l

There is indeed a cronjob starting every 15 minutes when I use your command. the job is as follows:

*/15 * * * * php -f /var/www/html/nextcloud/cron.php

I don´t recall adding this cronjob, maybe this one was added with the update from NC 14 to 15?
Would it be safe to comment this job?

In your Nextcloud web interface have a look at “admin/settings” e.g. /yournextcloud/admin/settings

The cronjob is listed there, I forgot I use this job for the News app (it fetches RSS news). Is this error due to the news app?

I use this cron-job myself for the news-app and I don’t get these errors. So frankly I don’t know…