Wordpress Error: Warning: Cannot modify header information

Advertisement

wordpress

Yesterday I was helping a reader solving his Wordpress error, so I thought I might as well write an entry, just in case we all encounter this in the future. If you ever run across this error (or warning) in your Wordpress with the message saying:

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

or something similar, chances are you have messed up your wp-config.php leaving some unnecessary spaces inside.

Solution

  1. Download your wp-config.php down via FTP (Edit directly if you have SSH access)
  2. Open wp-config with your favourite editor, and remove all spaces before "<?php" and after "?>"

    wordpress error

    wordpress error

  3. Upload and replace.

You are adviced to make backup of any files you edited.

Related Contents

Sponsors

Posted by hongkiat in Wordpress, Wordpress Tips Tricks , at 12.30.07

Tags: ,

Comments

  1. Eric Hamby January 22nd, 2008

    im getting this

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/20/d159566430/htdocs/jericoinfo/wp-includes/widgets.php:2) in /homepages/20/d159566430/htdocs/jericoinfo/wp-content/plugins/BAStats/BAStats_logger.php on line 99

    and of course i cant even log in or anything. the later part changed due to the page but the widgets.php seems to be the sourse of all the trouble. i looked through the file and there didnt seem to be any problems that i can see.. any ideas?

    please help

    http://jericosystems.info

    Reply
  2. Eric Hamby January 22nd, 2008

    just letting you know i fixed it so you didnt waste your time trying to help. feel free to stop by though.

    Reply
  3. Marian Matthis April 5th, 2008

    Thanks! I was having the same problem. Somehow, I ended up with spaces after “?>”, but getting rid of them fixed it!

    Reply
  4. HeyGabe April 12th, 2008

    Rock on! “chances are you have messed up your wp-config.php leaving some unnecessary spaces inside.”

    Exactly!

    Reply
  5. danielgbr June 21st, 2008

    Hey Hongkiat! I host my blog at Bluehost, installed wordpress and installed a theme called Demure Composure. Everytime i do anything i get a Header Error… when I log out via my blog i get this error:
    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-login.php on line 202

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-login.php on line 214

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 570

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 571

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 574

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 575

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 576

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 577

    Warning: Cannot modify header information – headers already sent by (output started at /home/ibawebco/public_html/jiba/wp-content/themes/Composure/functions.php:1190) in /home/ibawebco/public_html/jiba/wp-includes/pluggable.php on line 694
    What should I do!? I am totally a newb at this… thanx in advance

    Reply
  6. hongkiat June 21st, 2008

    @danielgbr double check your header.php. See if there’s a blank newline on the top of the page. Sometimes this error creates that following warning.

    Reply
  7. karol June 22nd, 2008

    it doesn’t work… :/

    Reply
  8. Jane Trimmer June 24th, 2008

    Thanks a lot for this! It was a great help and solved my problem.

    Jane

    Reply
  9. _Gian July 14th, 2008

    Thank you, you solved my problem.

    Reply
  10. blake July 24th, 2008

    Hi I have the same problem as you danielgbr….I have tried many things but nothing helped…where was the problem if you were able to fix it??

    Reply
  11. Jaime Creixems July 26th, 2008

    I can’t believe this, I told many of my clients that I cannot sell them WP in spanish because when I change the wp-config file to put it in spanish the WP messed up.

    I can’t believe this, you solved my problem, but is unbelievable that the spaces wer already there but only start messing around if I modify the file.

    Thanks a lot for fixing this serious WTF

    Reply
  12. RovingCalypso August 22nd, 2008

    I’ll be darned. I reinstalled the wordpress twice as I was getting this error when i upgraded.

    Who could’ve thought it were the space. Lol

    Reply
  13. Anouar August 24th, 2008

    Thanks, great post

    i had the same problem but i jut apply this solution (delete some space) and it work perfectly.

    Reply
  14. purab kharat August 25th, 2008

    i solved this problem
    use this code
    <?
    //dont use header function in wordpress-wp_signup.php
    global $domain;
    global $path;
    //change urlnew variable as per requirment
    $urlnew = “http://”.$domain.$path.”/wp-admin/admin.php;

    echo “”;
    echo “location = ‘$urlnew’;”;
    echo “”;
    echo $urlnew;
    ?>
    Purab Kharat

    Reply
  15. Beaulife September 21st, 2008

    Other than wp-config.php & header.php, any other possible cause of this error? I tried to delete those spaces but still the same problem. May I have your suggestions?

    Reply
  16. Beaulife September 23rd, 2008

    I just realized that the Google Analytic had created this trouble for my blog. I used to view my blog in Firefox but no error, but I found error from Google Analytic in IE. After I deactivated the Google Analytic Plugin, then all the problems solved. Just to share with all.

    Reply
  17. tkins recipes September 27th, 2008

    thanks for letting others know. this helped me out to when i encountered the problem

    Reply
  18. jen September 27th, 2008

    just wanted to let you know this saved me quite a bit of time tonight… thks for posting!

    Reply
  19. Gustavo D. September 30th, 2008

    Resolveu meu problema! Obrigado!

    Reply
  20. Aleks October 29th, 2008

    So simple, and yet effective. It helped me transfering my blog.

    Reply
  21. Raj October 31st, 2008

    Thank you dudes, it worked..

    Reply
  22. Boris December 3rd, 2008

    It worked for me! Removed to blank rows at the bottom

    Thanks.

    Reply
  23. Abs January 17th, 2009

    Thanks Bro, worked a treat after i removed the blank spaces.

    Reply
  24. Andy January 27th, 2009

    Hi,

    I had a similar problem and found it was caused by a recent update to one of my plugins, removed the plugin and this fixed the error.

    Andy

    Reply
  25. Fird February 3rd, 2009

    Thanks for the space tip. It’s been driving me nuts for hours!

    Reply
  26. cnpabi February 4th, 2009

    :)
    doesn’t work…

    Reply
  27. Alex February 6th, 2009

    Thanks, it solved the problem!

    Reply
  28. Javier February 7th, 2009

    Now I can start my blog. Thanks a lot!!!!!!!!!!!
    You are the best
    /Javier

    Reply
  29. Lindsey February 15th, 2009

    Thanks so much, this really helped me and saved a lot of time!

    Reply
  30. Bumpas March 13th, 2009

    You’re my hero. Thanks. It was so simple. I didn’t even see it.

    Reply
  31. Joreel March 13th, 2009

    Warning: Cannot modify header information in Wordpress

    I encountered the same problem… but I fixed using these following methods..

    http://emag.joreeldiaz.com/warning-cannot-modify-header-information-in-wordpress/

    Reply
  32. Mike Pantoja March 16th, 2009

    Holy Crap! All I had to do was check each file that showed up in the headers and TA DA! Problem solved. Thank you so much for posting this.

    Reply
  33. Girish March 16th, 2009

    Hi,

    When i am adding or deleting post in wordpres admin i am getting below error.

    Warning: Cannot modify header information – headers already sent by (output started at /home/content/d/i/c/diclemen18/html/wp/wp-admin/includes/file.php:1539) in /home/content/d/i/c/diclemen18/html/wp/wp-includes/pluggable.php on line 850

    Can anyone please help me.

    Thanks

    Reply
  34. Paul March 22nd, 2009

    Ja, genau so hatte ich es auch. Aber nun ist das Problem weg :)

    Reply
  35. Michael L. March 26th, 2009

    Wow, no friggin wayyyy. I have tried everything……. just as well as you all have im sure. And the freakin spaces were the problem. Im not sure which file, I went through a lot of em and almost cant believe that no more errors. :-) What a relief

    Reply
  36. Martijn March 27th, 2009

    Tnx! That solved it!

    Reply
  37. kristine April 29th, 2009

    I messed up my upgrade :( Please help. I tried doing what you said here…but to no avail…I can’t login to wp-admin too :(

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/6/d262576222/htdocs/wp-settings.php:630) in /homepages/6/d262576222/htdocs/wp-includes/pluggable.php on line 850

    Reply
  38. kristine April 29th, 2009

    i did it! :) figured out eventually…i had like 3 or 4 files that needed the editing and that was it :)

    thanks again for this info:)

    Reply
  39. josh May 5th, 2009

    Thanks for posting this, unfortunately the spaces wasn’t the problem but I saw a comment here about google analytics, so I removed the plugin and it works. thanks hongkiat & beaulife!

    Reply
  40. claudia June 3rd, 2009

    You have saved my hide! Thanks a billion! Now, how tha heck did that happen, I will never know…

    Reply
  41. Energy Care July 2nd, 2009

    Thanks!! this helped a bunch!! the problem ended up being a plugin i was using…random image generator…not sure what was not working, just deleted it and now im up and running!

    Reply
  42. TG July 31st, 2009

    Thanks! This was exactly the problem I had, and such a sneaky error to detect!

    Reply
  43. Sverre August 10th, 2009

    Thanks! that was the missing info I needed

    Reply
  44. Marius August 10th, 2009

    Hi, I’m having the same problem with BBPress, but theres no extra spaces in that file. Here is the errormessage:

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/backpress/class.wp-auth.php on line 273

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/backpress/class.wp-auth.php on line 273

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/backpress/class.wp-auth.php on line 273

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/backpress/class.wp-auth.php on line 273

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/backpress/class.wp-auth.php on line 273

    Warning: Cannot modify header information – headers already sent by (output started at /home/michael/public_html/forum/bb-config.php:1) in /home/michael/public_html/forum/bb-includes/functions.bb-pluggable.php on line 232

    Reply
  45. Sergey Rusak August 13th, 2009

    Thank you, it was easy. It took me 3 hours to figure out untill I found your post.

    Reply
  46. Rob Butz September 4th, 2009

    Hi folks. Well after looking at the error info, it looks as if the issue is NOT my wp-config.php or wp-login.php files but my themes functions.php file. I removed spaces at the end of that one.

    It makes sense as that could’ve been the only thing I might have modified and my site was “suddenly” not working.

    So.. checking your theme files functions.php is also recommended.

    Cheers

    R o B

    Reply
  47. nabtron September 27th, 2009

    the error is in the file that is being said in the error first line. this is caused by extra spaces before or after the php code

    check out the explaination here:

    http://tech.nabtron.com/wordpress-plugin-error-warning-session_start-function-session-start-cannot-send-session-cache-limiter-headers-already-sent-output-started-at/525/

    Reply
  48. Richard October 21st, 2009

    Got to say thank you, yesterday i locked down my site, and had to make small changes in the wp-config file

    any way today i had this error showing,

    then

    found you on google, made the small change of deleting the space

    and bingo my site is now up and running correctly..

    http://www.guesthousepattaya.com

    Thank you

    Reply
  49. Rob November 14th, 2009

    Thanks a lot, I had an error after installing a new theme so I went to the file specified and there was a blank line just like you mentioned. Erased the blank line and no more problems.

    Reply
  50. Jacob November 17th, 2009

    This worked for me! You are awesome!

    Reply

Leave a reply