Warning: Cannot modify header information

Warning: Cannot modify header information – headers already sent by (output started at… If your receiving an error like this in your web browser just after trying to edit a file, the culprit is most likely that there are spaces, misc characters or  newlines either just before an opening <?php tag or right after a closing ?> tag.  In WordPress, the problem may appear from a corrupt wp-config.php file. However, the problem can occur in other files as well.

Cannot modify header information – Examples

Warning Cannot Modify Header Information

Warning: Cannot modify header information – headers already sent by (output started at /home/username/public_html/wordpress/wp-config.php:2) in /home/username/public_html/wordpress/wordpress/wp-admin/theme-editor.php on line 70

Empty Lines before the opening <?php caused this error

Warning

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

Empty Lines after the closing ?> tag caused this error

How to fix the headers already sent Warning

  1. From the error message, locate the file that caused the error. This is reported by the section of the warning that starts (output started at…)
  2. Login to your server using an FTP client
  3. From your server, locate and download the culprit file to your computer
  4. Open the culprit file using a text editor and remove any extra spaces, lines or characters before the opening <?php or after the closing ?> tags
  5. Upload the file back to your server, overwriting the existing file if prompted
  6. Test to see if the error is fixed