What causes a “Cannot modify header information – headers already sent by” error?
Cannot modify header information errors are most commonly caused by extra white space in a PHP file. It’s usually added on accident when editing and modifying WordPress files. A single extra space can prompt this error. However, it’s also possible that you installed a plugin containing files that have an extra space, causing WP to throw this error up.
It will look something like this:
Warning: Cannot modify header information – Header already sent by (Output started at /blog/wp-config.php:31)
How to fix “Cannot modify header information…” errors
In order to fix the error, you have to first find out where it’s coming from. The error you see on the page will usually tell you where to look. In the example above, it’s in the wp-config file on line 31.
- Go to the file and line number it identifies to see if there are any extra spaces
- Make sure there are are no spaces before <?php at the beginning of the file
- Make sure there are no spaces after ?> At the bottom (If there is one, there does not have to be ?> at the end)
- Make sure there are no extra blank spaces at the end of the code, period
If you can’t find any extra spaces anywhere, it may be a plugin. Disable all your plugins and see if the error is gone. If so, turn them on one by one, checking after each one, to find the problem-causing plugin.
Note: If your site isn’t running on WordPress, the error should still tell you which file to start your search. Go to that file and look for any blank spaces as described above.