October 24, 2020


Thinking Magento

Cannot send headers; headers already sent

Have you started up your magento development site or live site to discover Cannot send headers; headers already sent. 

More often than not, this error is caused by the local.xml file not validating correctly after being edited for a server transfer.

Look at the following carefully, I've highlighted in bold where the mistake is normally made in the closing tags.


If you use web development software, you can paste it in to an xml file and validate it or download the file and validate it.

Not the error you were looking for?

Next thing to look at is if your index.php file has been edit. If any additional code has been added before <?php in the index.php file, it will start to throw up this error.

It will not show in your logs that the error is coming from the index.php file, so I've suggested looking at this file before enabling debugging logs.

Last but not least you can enable logging to find the file that is causing the error.

Open app/code/local/Mage/Core/Controller/Response/Http.php


Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true));



This will start saving to /var/log/system.log, look for the last entry and the error will be in that file.

Found the error and fixed it? Undo the changes you made to Http.php, otherwise that log will grow very quickly and bring your website to a standstill before long.