• Warning: Cannot modify header information – headers already sent…

    When moving a PHP application between servers or hosts, or updating your PHP, you may run into an error similar to something like this:

    Warning: Cannot modify header information - headers already sent by (output started at /path/to/site/public_html/config.php:517) in /path/to/application/public_html/somepage.php on line 153

    This is often referred to as a PHP whitespace problem, meaning somewhere in the PHP file there is an empty space, usually at the beginning or end of the file.

    Many people experience this when moving their PHP application such as WordPress to a new server/host, when upgrading PHP, or most likely when editing a PHP file with an editor. The problem is usually simply whitespace (in this case in config.php, line 517) that breaks the application. To fix the problem, remove the whitespace from the file.

    Read the error message, it says “output started at …” followed by a file name and a line number. That is the file and line that you need to edit. If you scroll to line 517 of config.php you will find the offending whitespace.

    You can run different scripts to help eliminate the whitespace, such as the ruby script here.


    Leave a reply