WordPress Error – Headers Already Sent Warning Problem

Yesterday I almost became tensed. Some tutorials on the net are really lame! 😛 I trusted a site and applied that tutorial directly on my blog, and the result became sh*t. I highly recommend you to try tutorials on a demo blog rather than on your primary site or blog.

Yesterday I came across this unique WordPress error titled “Cannot modify header information – headers already sent by …” [Without Quotes]

Though, this tutorial is 99.9% perfect, I recommend you to backup all your theme files before implementing this tutorial. Happy Blogging!

I’ll tell you what mistake I did and how to resolve that.. 8)

Description :

You get a warning message on your browser that says:

Warning: Cannot modify header information – headers already sent by (output started at

Example :

Warning: Cannot modify header information – headers already sent by (output started at //home/htdocs/wordpress/wp-config.php:1) in /home/htdocs/wordpress/wp-login.php on line 12

WP-Error-close

Reason :

The reason is simply simple. It is usually because there are spaces, new lines, or other garbage before an opening < ?php tag or after a closing ?> tag, most probably in wp-config.php. It may also occur in other files too, so please check the error message. Many editors are adding additional blanks (spaces) and empty lines at the end of a file when you edit it.

Solution :

The best solution I would say is to replace the corrupted file with the file you have in your backup. You can also try the following alternative steps!

#1 – Download the file mentioned in the error message.

#2 – Now open that file using a really good Text Editor. It should be a plain text editor. I highly recommend Notepad++ or TextWrangler.

P.S. Don’t risk. Avoid Notepad, WordPad and even MS Word.

#3 – Now check that the very first characters are < ?php and the very last characters are ?>

Most Important!

You should save your file either as ANSI/ISO-8859 or as Unicode without BOM. Don’t ever save in normal format.

Have you ever faced this problem? Do you any other solution for solving this?

21 thoughts on “WordPress Error – Headers Already Sent Warning Problem”

  1. Thanks Kumar! I’ve been getting those errors in a couple of little websites. Now I know what the heck is going on and have written on it also

    Reply
  2. Wow, Thank you very much. I got the same problem but in pluggable.php file. But which ever the file is the solution is exactly what you said. Its only the empty lines at end of the file.

    Reply
  3. Great post. Just received this error for the first time and couldn’t figure out why. I had copied some code to a functions.php file from another tutorial and it must have included some hidden spaces. Thanks for helping me fix it.

    Reply
  4. This is one of the most common problems which I faced when I was updating or tweaking my blog. All the times, I used to deactivate the newly being used plugin and try to refresh the page which used to work perfectly.

    This is a minute thing which I missed and you have covered very well in this post.

    Reply
  5. Nice tips, I have not seen this type of error message on my blog, thanks for sharing the solution, I now know the error and how to resolved it, if such error occur in my blog.

    Reply
  6. Yep, i learned this the hard way as well, now i always try upgrade, experiements and sometimes even new plugins on my smaller and less important blogs. Messing up the main blog give a heart attack sort of a feeling 😛

    i had faced a similar problem, thanks to my exceptional coding talent, i never bothered/dared to do more editing, i uploaded the file from the backup and things were all right.

    Reply
  7. Pradeep I have seen your site behaving abnormally when you were making the change.

    Glad that it is fine now.

    Nice tut BTW.

    Reply
  8. Nice post and fantastic job done.First time came to know so many errors code and meaning. How to take care of them ill be easy if you understand them.Back up your thing always safe than lost.Thanks for knowledge sharing specially for those who are using wordpress stuffs.

    Reply
  9. I have faced this weird problem while I was developing my theme. It got solved by re-arranging the header content then.

    Reply
    • Haha… Man, how many times you don’t get this problem? Today, while installing a new plugin, I got into a little bit adventurous mode and started editing without a backup on notepad. Finally it turned out that the crappy notepad put some extra characters before the open php tag. It wasn’t visible in UTF encoding but when I switched to unicode, those little monsters appeared.. Very useful post man.

      Reply
  10. I too faced this problem when I was designing wordpress theme and I solved the problem by removing white spaces only.

    Reply
  11. So far no, but i am sure this will help me in future when i face such errors. Seeking for valid source of problem solving is highly recommended.

    Cheers.

    – Robin

    Reply
  12. Nice work mate!! I’ll seek your help if I overcome any WordPress error like this, ;)..

    Before that, I think you did some editing work in your WP, May i know what you did?? & Why you got this error??

    Reply
  13. cool article mate!!!!
    Its good that you are posting these sort of articles related to wordpress these are really usefull 🙂 🙂

    Reply

Leave a Comment