How to Fix Warning: Cannot modify header information – headers already sent Error Message in WordPress

After transferring my WordPress site to a new server, I received this error when trying to log in to the WP-Admin panel

Warning: Cannot modify header information – headers already sent by (output started at /home/nnnick/public_html/nickroshon.com/wp-content/plugins/wp-security-scan/scanner.php:63) in /home/nnnick/public_html/nickroshon.com/wp-includes/pluggable.php on line 890

I had no idea what that means, but without being able to log in to the Admin panel it was a little hard to get rid of it. At first I thought about just going in and deleting the plug-in referenced above and seeing if that would work (it did work, although there were many other plugins that were also causing this error, as well as the theme itself, which I didn’t want to delete!). Given I didn’t want to delete all of my plugins as well as the theme itself, I began exploring other options.

Upon doing a Google search for this error, I found many helpful articles, but none that were quite helpful enough – they give tips, but some of the details were a bit fuzzy. This post on WPContempo, as well as these two posts on the WordPress.org forums (1) and (2) were helpful, and explained that:

You likely have an extra white-space or line at the beginning or end of your WP-Config file. Open your WP-Config file and delete an extra white-space at the beginning or end of the file, then delete it.

That is mostly correct, but a little unclear and didn’t totally fix my problem. Here is the dumbed down explanation.

  1. You probably do have extra lines at the beginning or end of a file, although it isn’t necessarily your WP-Config file. If your error message looks like mine above, it is in a specific file related to a plugin, theme, or other add-on to your WordPress install, although its possible your WP-Config file also has extra white space too. During the transfer of your site, some of your files (for whatever unknown reason) grew a few mysterious empty lines at the beginning or end, which screws everything up… ¬†Extra Spaces at End of File WordPress
  2. To find the files with the extra lines, look at the error message itself, as it will tell you exactly which file is causing the issue. At the example at the top of this post, “Warning: Cannot modify header information – headers already sent by (output started at /home/nnnick/public_html/nickroshon.com/wp-content/plugins/wp-security-scan/scanner.php:63) in /home/nnnick/public_html/nickroshon.com/wp-includes/pluggable.php on line 89″ the part bolded is the cause of your problem. It is telling you the Scanner.php file has an extra space on line 63, which happened to be the last line of the file (and sure enough, it was blank).
  3. To fix it, either connect to your site via FTP, or through the File Manager in your cPanel (note: connecting via FTP is better as the cPanel may add extra lines itself, although I had no problem doing this through the cPanel myself). Within either your FTP or cPanel File Manager, navigate to the location of the file causing the problem (public_html/nickroshon.com/wp-content/plugins/wp-security-scan/) in this example, and then open the file name referenced (scanner.php). Look for the line number after the colon, again in this example line 63. Remove the extra lines starting at that line number, and then save the file and close it.
  4. Try reloading your WP-Admin page. Chances are you’ll see the same error message again, only a new file is causing the problem…repeat steps 2-3, looking for that exact file and line number and removing spaces. With one of my rather customized blogs I had to do this probably 10 times before I could get rid of all the error messages, but eventually I had corrected all of them, and am now able to log in to my WP-Admin just fine!

And that’s it – I hope this was helpful to others out there that may have had some problems like me. It is definitely something you can figure out, even if you’re not an expert programmer – you just need a little patience as it is a tedious process of hunting for extra spaces and lines.

If you enjoyed this post, please share it!
  1. I have been dealing with a WordPress move for about the last 18 hours. I read everything you mention in this post and just didn’t get it. Finally, I deleted the entire top line “<?php" and saved the file, it worked perfectly. You did a great job of explaining this issue. Thanks!

    • Georgiana
    • August 11th, 2013

    Hello,

    I had a similar problem. Thanks to your explanation I manager to resolve the issue. Thank you!

    • RG
    • March 21st, 2014

    Thanks a lot!

  1. No trackbacks yet.