Tag: wordpress Warning: Cannot modify header information – headers already sent by

6

We have run into quite a few people lately getting this error on their WordPress installation, so we figured we’d post the solution here as a quick fix for anyone else having similar issues.

The error will appear something like this:

Warning: Cannot modify header information – headers already sent by (output started at //home/wordpress/wp-config.php:1) in /home/wordpress/wp-includes/pluggable.php on line xx

Of course the locations of the files listed in the warning will vary based upon your installation.

The likely culprit, believe it or not, are spaces.   Most likely while making some modifications to your store you inadvertantly left in a space either before the beginning < ?php tag, or after the last/terminating ?> tag within the page.

  1. Download the first file listed in the warning message (we recommend taking a backup copy, just in case).   In the warning message above, it would be //home/wordpress/wp-config.php.   We've also seen the error pop for spaces on wp-login.php pages, as well as the functions.php page within your theme folder (to name just a few).
  2. Once the page is loaded, simply make sure the FIRST thing listed in the file is a < ?phptag, and if there are any spaces before it, delete them.
  3. Similarly, if the page ends in a ?> tag (not all do), make sure any spaces after that are deleted.
  4. Save the file, and re-upload overwriting the old version of the file.

  5. Thats it!   In 99% of cases this should fix your "cannot modify header information" errors within WordPress.

    Cheers!