Warning: Cannot modify header information – headers already sent

Reading Time: 2 minutes

Seen this one? Probably yes, if you are a regular WordPress user.

As you probably know the web page usually consists of several parts which include a header, a body, and a footer. And in case that the page header is coded incorrectly or there is some sort of conflict between scripts then the following error can occur. The error is usually displayed on the site front-end and usually there is a path that tells you the exact file that is producing the error and even on which line.

Here are some fixes and checks that you can try yourself if you happened to stumble on this issue:

– check for blank lines at the top of the file on which the issue occurs and also in the file wp-config.php. There should not be any blank lines or spaces before the opening PHP tag “<?php“. And also check for the same but this time after the closing PHP tag “?>”

– check for spaces before or after the opening tag “<?php” and again check for any spaces before or after the closing tag “?>”. If the document does not have a closing tag make sure that there are no spaces after the last char of the file

– if the issue is with a core WordPress file you can simply try to replace it with a fresh copy of the file. If it is a part of a plugin you can deactivate, then completely delete the plugin and then re-install it again.

  Error Establishing A Database Connection

– make sure that the file encoding is plain UTF-8

– if you have used some custom code in some files and they are now outputting this error check for the following functions in the file:

header()
header_remove()
session_start()
session_regenerate_id()
setcookie()
setrawcookie()

If you have checked and tried all of the above and the issue still pops up then feel free to get in touch and we will further look into the matter.

Inquire About Warning: Cannot modify header information – headers already sent

Share us all the details you have so we can start working on your WordPress website immediately!