Warning: Cannot Modify Header Information - Header Already Sent

Sometimes, you may encounter an error that goes along the lines of: “Warning: Cannot modify header information — headers already sent by (output started at /path-to-something-directory/some-config-file:xyz )”.

This error is caused by the unrequired spaces in the mentioned WordPress file (generally, it is the wp-config.php file). Naturally, you will need to edit the concerned file to remove the unnecessary whitespaces.

The Cure

Download the file that is mentioned in the error (say, wp-config.php). Open it using an editor of your choice, and then ensure that there are no spaces either before <?php or after ?> tags. Overall, the first letters of the file should be <?php and the last letters should be ?> (with absolutely no spaces between ‘?’ and ‘<’ or ‘>’ either).

As already mentioned, most of the time this error happens due to spaces in the wp-config.php file. It can be some other file too, though — just read the error carefully because it specifies the file name and the path to the concerned file.

Was this article helpful?
0 out of 0 found this helpful