Headers already sent in Pluggable.php / homepage and wp-login error

After migrating site to another account on same host, I started to receives strange errors. Firstly I encountered an error where at the login page I was asked to turn on Cookies.
And after I deleted that part of the file in wp-login.php (I turned off that test cookie wp is setting when user is wp login screen).

Nowm when I visit my site without www, so just domainname.com, and when I visit wp-login.php and try to log in, I get a
Headers already sent error, for file pluggable.php on line 897

Read More

I tried all standard solutions including:

  • Downgrading WordPress
  • Reseting plugins folder
  • Checked if my files are started and ended regulary with
  • Checking sites URL in phpMyAdmin, reseting permalink structure

My sites on two accounts have exact same files, dbs and settings I have properly done the migration itself, and changed the links in the database. Both of the sites are on new server, that has exact same configuration 🙂

Any ideas?

Thanks in advance

Related posts

Leave a Reply

5 comments

  1. It is usually because there are spaces, new lines, or other stuff before an opening tag, typically in wp-config.php. This could be true about some other file too, so please check the error message, as it will list the specific file name where the error occurred.

    Other Resources:

  2. I had the same error. The problem was I had multiple php tags. Just use a single set.
    Ie:

    ==== BAD ====

    <?php 
       abc;
    ?>
    <?php
       def
    ?>
    

    ==== GOOD ====

    <?php
       abc;
       def;
    ?>
    
  3. Headers already sent error, for file pluggable.php on line 897

    You need a solution to the problem above, and that is very easy. Reinstall a fresh copy of WordPress

    I was asked to turn on Cookies. And after I deleted that part of the file in wp-login.php (I turned off that test cookie wp is setting when user is wp login screen).

    There is no bigger sin in WordPress programming than to hack, change, delete or add any type of code, no matter how small to core files, themes and plugins. And excuse me for shouting, but NEVER EVER, AND I MEAN EVER, DO THAT!!!!!!

    WordPress are coded and tested by some of the top coders in the world. All new versions goes through very tough testing, and by the time a new version goes live, all bugs are sorted. WordPress developers also keep WordPress up-to-date and new versions are regulary released. So, if anything goes wrong with your installation, 99.99999% it is not WordPress.

    That said, even if a problem is related to the core, YOU SHOULD NEVER EVER CHANGE CORE FILES, PERIOD.

    The same apply to themes and plugins that aren’t yours. Theme files and plugin files should also never ever be changed, and like in never, and only when you are the author. That is what child themes are for.

    Why should you never change core, theme or plugin files? The answer is simple, As with WordPress core, many themes and plugins available, updates are always available, and if you made any changes to these files, your changes will be overwritten, and you will loose them for ever, and there is no turning back.

    Always always use a child theme, and always always make changes inside that child theme. As previously said, the only time you can change theme and plugin files is when you are the author.

    That said, what should you do if you encounter a problem?

    Debug, debug, debug, always debug. That is one aspect that so many miss, and most of the time setting debug to true in wp-config.php will exactly print your problem, so you will immediatly know where to start looking.

    if debugging gives up nothing, you should firstly deactivate all plugins, one by one, and check after each one if the problem remain or if it is solved. Most of the time this will solve your problem. If that doesn’t work, deactivate your theme and activate one of the default themes that is shipped with wordpress. If that solves your problem, you know it is your theme. If your problem however remain, your problem is usually core related or server related. If you suspect it might be the core that is corrupt, just install a fresh copy. (Always make a backup before you do that). If it is server related, it is always a great idea to speak to your hosting provider first.

    I would urge you, reinstall a fresh copy of wordpress and start from the top and follow my instructions, and if that doesn’t solve your problem, or if you are unsure what is causing it, edit your question or start a new one with the details of the actual problem ” I was asked to turn on Cookies”.

    I hope this not only helps you, but everyone how finds this page.