Session_name(): Cannot change session name when headers already sent

Since last night, without running any updates or changing any configuration files, I see this message on every page (I enabled debugging to see the detailed message, of course):

Internal Server Error

The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.
Technical details

    Remote Address:
    Request ID: xxxxxxxxxxxxxxxxxxxxx
    Type: ErrorException
    Code: 0
    Message: session_name(): Cannot change session name when headers already sent
    File: /var/www/nextcloud/lib/private/Session/Internal.php
    Line: 185


#0 [internal function]: OC\Session\Internal->trapError(2, 'session_name():...', '/var/www/nextcl...', 209, Array)
#1 [internal function]: session_name('ocm95q6lftf5')
#2 /var/www/nextcloud/lib/private/Session/Internal.php(209): call_user_func_array('session_name', Array)
#3 /var/www/nextcloud/lib/private/Session/Internal.php(55): OC\Session\Internal->invoke('session_name', Array)
#4 /var/www/nextcloud/lib/base.php(417): OC\Session\Internal->__construct('ocm95q6lftf5')
#5 /var/www/nextcloud/lib/base.php(639): OC::initSession()
#6 /var/www/nextcloud/lib/base.php(1076): OC::init()
#7 /var/www/nextcloud/index.php(35): require_once('/var/www/nextcl...')
#8 {main}

I noticed that the occ command’s output starts with a strange string:

/var/www/nextcloud $ sudo -u www-data php occ
msgid "Cambodia"
msgstr ""

#: lib/Horde/Nls/Countries.php:46 lib/Horde/Nls/Tld.php:61
msgid "Cameroon"
msgstr ""

#: lib/Horde/Nls/Countries.php:47 lib/Horde/Nls/Tld.php:52
msgid "CanaNextcloud 21.0.2

  command [options] [arguments]

Can’t find other useful information in logs. Any idea how to solve this problem?


Nextcloud 21.0.2

Operating system and version: Raspbian GNU/Linux 10 (buster)

Server version: Apache/2.4.38 (Raspbian)
Server built: 2020-08-25T20:08:29

PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )

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

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

$CONFIG = array (
  'instanceid' => 'xxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => '',
  'datadirectory' => 'xxxxxxxxxxxxxxxxxxxx',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
  'maintenance' => false

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

1 Like

This problem was caused by the mail app. I disabled it, and now everything is back to normal. From inside the nextcloud folder:

$ sudo -u www-data php occ app:disable mail
mail 1.10.2 disabled