WordPress Error: Warning: Cannot modify header information

Advertisement

wordpress Wordpress Error: Warning: Cannot modify header information

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.

Share!

Enjoy the article so far? Recommend it to your friends and peers.

Subscribe! (free)

Be the first to our articles and get latest updates on freebies.

Advertisement

  • Thanks, Totally solved my problem.
    I use wpmu
  • Jeez!

    6 files I edited all from wp-cache folder
  • I had this problem and turned out it was because I used multiple PHP tags, instead of one at the beginning and one at the end.

    My wp-config was also missing PHP closing tags, which I found rather odd to say the least...
  • bob
    I got the same problem.

    already fixed. tnx
  • Thanks! Totally solved my problem. Mine was actually occurring in my theme's "functions.php" file. I just downloaded it via FTP, opened it up in a text editor and removed the lines after the closing php statement (ref. '?>'). I wonder why this happens?
  • Therm
    I'm using the "health Iced mate" theme right now. I changed some code, and tried to change it back but now it won't save.
    I replaced(on line 33):
    /images/btn-search.jpg" />
    with:
    /images/EMA-logo.jpg" />
    saved it,
    and tried to put back:
    /images/btn-search.jpg" />

    but it wont save!! what am i doing wrong?
    any help would be appreciated. thanks!

    all i want to do is change my heading to display my own logo
  • Digitalpbk
    This message can be solved by various methods. See
    http://digitalpbk.com/php/warning-cannot-modify...
  • ha ha! how crazy the problem is !! BUT i finally deal it ! thx u~
  • I found that the required php ending code ?> had been totally removed from 2 of my WP pages (wp-config.php and pluggable.php).

    I think it was caused by updating some plugins.

    This has happened to me before a long time ago, but your post helped to remind me of how to locate the problem.

    Thanks,

    ~Jeff
    MileHighTechGuy
  • wow, that was easy. thank u!
  • hi,

    i'm stuck with this message...

    Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home95b/sub003/sc1084932-QQGK/willvandewiel.com/wp-content/plugins/google-news-widget/google-news-widget.php:1) in /mounted-storage/home95b/sub003/sc1084932-QQGK/willvandewiel.com/wp-login.php on line 302

    Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home95b/sub003/sc1084932-QQGK/willvandewiel.com/wp-content/plugins/google-news-widget/google-news-widget.php:1) in /mounted-storage/home95b/sub003/sc1084932-QQGK/willvandewiel.com/wp-login.php on line 314


    i don't have ftp set up for the site and i cant log into the wordpress acc either. completely stuck and getting grief from the boyfriend please help!!!

    Thanks!
  • rob
    Thanks - you are still helping people over two years later!
  • Thanks for solution, many problem solved, my http://domain.com and http://www.domain.com/wp-admin have same error, i solved using removing space after ?>

    earlier my site was hacked by ftp password compromise through ftp my hosting provider remove infected script but space after ?> was left, i solved this

    thanks
  • Thank you for this post. I just created my first plugin and widget, and I was receiving a similar error with headers. I removed all the unnecesary spaces in the code and now it works.
  • Brad
    Thanks! Fixed my problem!
  • Hey, nice article and useful comments. None of the comments helped me though. I finally found my solution buried in one line of the wordpress troubleshooting guide. "Also check the encoding of the file. If the file is encoded as UTF-8 with BOM, the BOM is seen as a character which starts the output." (from: http://bit.ly/by8n5x). I was developing a Chinese localisation, and had inadvertently enabled the BOM in the file editor I was using. Lesson, check your php file encoding and if in doubt set it to ANSI and see if that fixes your problem.
  • Top tip and solved the problem. Thanks
  • Thanks for posting this! You saved me after countless hours… :)
  • Thanks, this really helped me out!
  • güzel paylaşım
  • Thanks SO much for this quick fix!!! Saved me so much time!
  • Thanks - VERY HELPFUL!
  • Anthony
    Sorry my above post didnt show any code^^^

    I just downloaded the newest version of Wordpress and all I did was modify wp-config.php. There were no spaces before"".However the problem still exists. My website shows up fine, I just get the error when i am at the wp-login.php file

    Any any other suggestions?
  • Anthony
    I just downloaded the newest version of Wordpress and all I did was modify wp-config.php. There were no spaces before at the end. So i added it in and made sure there were no white-spaces. However the problem still exists, any other suggestions?
  • This worked for me! You are awesome!
  • Rob
    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.
  • 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-...
  • Rob Butz
    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
  • Thank you, it was easy. It took me 3 hours to figure out untill I found your post.
  • Sverre
    Thanks! that was the missing info I needed
  • TG
    Thanks! This was exactly the problem I had, and such a sneaky error to detect!
  • Energy Care
    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!
  • You have saved my hide! Thanks a billion! Now, how tha heck did that happen, I will never know...
  • 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!
  • 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:)
  • 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
  • Tnx! That solved it!
  • Michael L.
    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
  • Ja, genau so hatte ich es auch. Aber nun ist das Problem weg :)
  • Girish
    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
  • Mike Pantoja
    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.
  • 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-modif...
  • You're my hero. Thanks. It was so simple. I didn't even see it.
  • Lindsey
    Thanks so much, this really helped me and saved a lot of time!
  • Now I can start my blog. Thanks a lot!!!!!!!!!!!
    You are the best
    /Javier
  • Thanks, it solved the problem!
  • :)
    doesn't work...
  • Thanks for the space tip. It's been driving me nuts for hours!
  • 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
  • Abs
    Thanks Bro, worked a treat after i removed the blank spaces.
  • Boris
    It worked for me! Removed to blank rows at the bottom

    Thanks.
  • Raj
    Thank you dudes, it worked..
  • So simple, and yet effective. It helped me transfering my blog.
  • jen
    just wanted to let you know this saved me quite a bit of time tonight... thks for posting!
  • thanks for letting others know. this helped me out to when i encountered the problem
  • 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.
  • 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?
  • 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
  • Thanks, great post

    i had the same problem but i jut apply this solution (delete some space) and it work perfectly.
  • 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
  • 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
  • blake
    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??
  • Thank you, you solved my problem.
  • Jane Trimmer
    Thanks a lot for this! It was a great help and solved my problem.

    Jane
  • karol
    it doesn't work... :/
  • @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.
  • 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
  • Rock on! "chances are you have messed up your wp-config.php leaving some unnecessary spaces inside."

    Exactly!
  • Thanks! I was having the same problem. Somehow, I ended up with spaces after "?>", but getting rid of them fixed it!
  • just letting you know i fixed it so you didnt waste your time trying to help. feel free to stop by though.
  • 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
blog comments powered by Disqus