How to Fix “Cannot modify header information – headers already sent” error in Wordpress

This is the most frequently asked question on troubleshooting wordpress. After modifying a file or transferring/replacing a file using ftp, or after adding some code to functions.php, you must have seen an error similar to this-

Warning: Cannot modify header information – headers already sent by (output started at /path/to/yoursite/public_html/index.php:581) in /path/to/yoursite/public_html/blog/errorfile.php on line 15

This error message signifies that there are some stray characters, like spaces, before the opening tag(<?php) or after the closing tag(?>) of the php file that generated the error (errorfile.php in our case, see the error message above).

To fix this error download the file causing the error using ftp (It is the file at the end of the error message).

How to Fix Cannot modify header information   headers already sent error in Wordpress

Now open the file in any plain text editor, for windows use notepad. Move the cursor to the start of the file and delete all the spaces there. Make sure that the file starts with <?php. Note that some files can starts with HTML tag like <div id=”hacktrixRocks”>. Skip this step if this is the case.

How to Fix Cannot modify header information   headers already sent error in Wordpress

Now move the cursor to the end of the file and delete all the spaces after ?>.

How to Fix Cannot modify header information   headers already sent error in Wordpress

Now save the file and replace the original file in your web directory with this file using FTP. That’s it.

Speak Your Mind

Tell us what you're thinking...