Troubleshooting "Cannot modify header information - headers already sent" Errors
Troubleshooting "Cannot modify header information - headers already sent" Errors
Date Published: March 4, 2022
Issue
Single Sign-On (SSO) may suddenly stop working, and errors in the logs like this may appear:
Warning: Cannot modify header information - headers already sent by (output started at /mnt/www/html/example/vendor/symfony/http-foundation/Response.php:377) in Drupal\simplesamlphp_auth\Controller\SimplesamlphpAuthController->authenticate() (line 197 of /mnt/www/html/example/docroot/modules/contrib/simplesamlphp_auth/src/Controller/SimplesamlphpAuthController.php)
Resolution
If you're encountering this on all of your environments, then it's possibly related to code, specifically a module you might have enabled recently. Though the above is specific to SimpleSAML, a post on Drupal's Stack Exchange for troubleshooting an issue like this in general recommends disabling/uninstalling the most recently installed modules until you can isolate which module is at play. Even if it seems unlikely that a module is at play, disable it to at least rule it out as a cause. If you're able to re-enable the modules you absolutely need and logging in works, then do the same thing in the production environment.