Cannot modify header information

Longtime lurker, first time poster. I’m driving myself crazy with this one. Any help is appreciated!

Nextcloud version: 17.0.1.1
Operating system and version: dietpi
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.1): I believe this is 7.3

The issue you are facing:

I am suddenly unable to access Nextcloud at all. I can’t access on Android or in a browser. I get the standard
" Internal Server Error

The server was unable to complete your request."

I have no idea what changed. Everything was working alright.

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Enter the external IP/nextcloud into a browser or the internal IP/nextcloud.
  2. OR enter the externalIP/nextcloud on the Android app. Same goes for internal IP. Android gives the “malformed server configuration” error or just times out.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"QxnRZlta1glITkZzAmI9","level":3,"time":"2020-03-25T15:25:46+00:00","remoteAddr":"[External IP]","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/","message":"ini_set(): Headers already sent. You cannot change the session module's ini settings at this time at \/var\/www\/nextcloud\/lib\/base.php#408","userAgent":"Mozilla\/5.0 (Linux; Android 10; Pixel 4 X$

{"reqId":"QxnRZlta1glITkZzAmI9","level":3,"time":"2020-03-25T15:25:46+00:00","remoteAddr":"External IP]","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/","message":"ini_set(): Headers already sent. You cannot change the session module's ini settings at this time at \/var\/www\/nextcloud\/lib\/base.php#412","userAgent":"Mozilla\/5.0 (Linux; Android 10; Pixel 4 X$

{"reqId":"QxnRZlta1glITkZzAmI9","level":3,"time":"2020-03-25T15:25:46+00:00","remoteAddr":"External IP]","user":"--","app":"base","method":"GET","url":"\/nextcloud\/","message":{"Exception":"ErrorException","Message":"session_name(): Cannot change session name when headers already sent","Code":0,"Trace":[{"function":"trapError","class":"OC\\Session\\Internal","type":"->","$

{"reqId":"QxnRZlta1glITkZzAmI9","level":3,"time":"2020-03-25T15:25:46+00:00","remoteAddr":"External IP]","user":"--","app":"no app in context","method":"GET","url":"\/nextcloud\/","message":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"news.page.index\" as such route does not exist.",$

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

<?php
<?php
$CONFIG = array (
  'instanceid' => 'instanceid',
  'passwordsalt' => 'passwordsalt',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => '[local domain IP]',
    1 => '[External IP]',
   ),
  'datadirectory' => '/datastore',
  'dbtype' => 'mysql',
  'version' => '17.0.1.1',
  'overwrite.cli.url' => 'http://192.168.0.x/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'dbuser',
  'dbpassword' => 'dbpassword',
  'installed' => true,
  'maintenance' => false,
);

The following was recorded in the log just now after a login attempt from a mobile browser.

{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#96","userAgent":"--","version":"17.0.1.1"}
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#101","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#102","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#103","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#104","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#105","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#106","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/legacy\/response.php#107","userAgent":"--","version":"17.0.1.1$
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/base.php#493","userAgent":"--","version":"17.0.1.1"}
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/base.php#493","userAgent":"--","version":"17.0.1.1"}
{"reqId":"bIHygEwjkZAbgnAeFCT7","level":3,"time":"2020-03-26T04:50:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/nextcloud\/config\/config.php:1) at \/var\/www\/nextcloud\/lib\/private\/Session\/CryptoWrapper.php#89","userAgent":"--","version":"17.$

maybe-similar situation since today (or maybe yesterday):
web ui is text-only for alraedy logged-in sessions & login button doesn’t react for new sessions.

tail -n 2 nextcloud.log:

{"reqId":"nbVs30VnYGyJrQjVYdMm","level":3,"time":"2020-03-26T11:54:16+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/html\/owncloud\/config\/config.php:1) at \/var\/www\/html\/owncloud\/lib\/base.php#507","userAgent":"--","version":"15.0.2.0"}
{"reqId":"nbVs30VnYGyJrQjVYdMm","level":3,"time":"2020-03-26T11:54:16+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Cannot modify header information - headers already sent by (output started at \/var\/www\/html\/owncloud\/config\/config.php:1) at \/var\/www\/html\/owncloud\/lib\/base.php#507","userAgent":"--","version":"15.0.2.0"}

And some database-related error message:
tail -n10 /var/log/apache2/error.log:

[Thu Mar 26 11:17:39.132219 2020] [mpm_prefork:notice] [pid 2045] AH00169: caught SIGTERM, shutting down
[Thu Mar 26 11:18:35.535443 2020] [mpm_prefork:notice] [pid 2143] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Thu Mar 26 11:18:35.536592 2020] [core:notice] [pid 2143] AH00094: Command line: '/usr/sbin/apache2'
[Thu Mar 26 11:30:17.137139 2020] [mpm_prefork:notice] [pid 2143] AH00169: caught SIGTERM, shutting down
[Thu Mar 26 11:31:17.848409 2020] [mpm_prefork:notice] [pid 2208] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Thu Mar 26 11:31:17.858931 2020] [core:notice] [pid 2208] AH00094: Command line: '/usr/sbin/apache2'
[Thu Mar 26 11:40:10.969497 2020] [php7:error] [pid 2433] [client 188.192.198.229:48372] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/owncloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/owncloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\ in /var/www/html/owncloud/lib/private/DB/Connection.php on line 64
[Thu Mar 26 11:40:10.970225 2020] [php7:error] [pid 2433] [client 188.192.198.229:48372] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/owncloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/owncloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\ in /var/www/html/owncloud/lib/private/DB/Connection.php on line 64
[Thu Mar 26 11:40:11.079799 2020] [php7:error] [pid 5870] [client 188.192.198.229:48374] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/owncloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/owncloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\ in /var/www/html/owncloud/lib/private/DB/Connection.php on line 64
[Thu Mar 26 11:40:11.080443 2020] [php7:error] [pid 5870] [client 188.192.198.229:48374] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/owncloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/owncloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\ in /var/www/html/owncloud/lib/private/DB/Connection.php on line 64

(but connecting to mysql via command line as the owncloud user works fine)

nextcloud: 15.0.2.0
php: 7.2.24
os: ubuntu 18.04.4

seems to be fixed after update to nextcloud 18.0.3

Yep. Looks like the update fixed it! Thanks!

Back again.

1 Like

I had the same issue (NC 19.0.4)
I had configure an external storgae to a SMB share that was off-line.
I remove the configuration and all works well