Question

Hello everyone I am getting an error that I cannot seem to fix.

a:5:{i:0;s:93:"Cannot send headers; headers already sent in /home/exowear/public_html/app/Mage.php, line 766";i:1;s:1013:"#0 /home/exowear/public_html/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/exowear/public_html/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...')
#2 /home/exowear/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse()
#3 /home/exowear/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(202): Mage_Core_Controller_Varien_Front->getResponse()
#4 /home/exowear/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#5 /home/exowear/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /home/exowear/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#7 /home/exowear/public_html/index.php(87): Mage::run('', 'store')
#8 {main}";s:3:"url";s:10:"/index.php";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

I am trying to set it up on the live domain, but I keep running into this. It is working fine on my test server. http://mytempsite.net/sin but when I bring it over to http://vegassinexoticwear.com I get this error.

What I Tried

  • I backed up the entire directory on my temp site and brought it over to the new server using SSH. Then I exported the DB and Imported it into the new DB. Changes the URL in the core_config_data table. Cleared the cache and even checked permissions.
  • I installed a new copy of magento and brought over the app, skin, and media folders all separately. Before bringing it over there were no errors but once I brought the app folder over I got this error again.

Why does it work on one server and not on the other server?

EDITED/ ADDITIONAL DETAILS this is the error I am not getting when trying to go to the site.

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 4: parser error : StartTag: invalid element name  in /home/exowear/public_html/sin/lib/Varien/Simplexml/Config.php on line 510

#0 [internal function]: mageCoreErrorHandler(2, 'simplexml_load_...', '/home/exowear/p...', 510, Array)
#1 /home/exowear/public_html/sin/lib/Varien/Simplexml/Config.php(510): simplexml_load_string('loadString('loadFile('/home/exowear/p...')
#4 /home/exowear/public_html/sin/app/code/core/Mage/Core/Model/Config.php(315): Mage_Core_Model_Config->_loadDeclaredModules()
#5 /home/exowear/public_html/sin/app/code/core/Mage/Core/Model/App.php(414): Mage_Core_Model_Config->loadModules()
#6 /home/exowear/public_html/sin/app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#7 /home/exowear/public_html/sin/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#8 /home/exowear/public_html/sin/index.php(87): Mage::run('', 'store')
#9 {main}

When I go look at Config.php line 510 this is what is there

$xml = simplexml_load_string($string, $this->_elementClass);

The whole function is this

 */
public function loadString($string)
{
    if (is_string($string)) {
        $xml = simplexml_load_string($string, $this->_elementClass);

        if ($xml instanceof Varien_Simplexml_Element) {
            $this->_xml = $xml;
            return true;
        }
    } else {
        Mage::logException(new Exception('"$string" parameter for simplexml_load_string is not a string'));
    }
    return false;
}

My local.xml file was saved making sure BOM was unchecked in DW CS6

 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 /**
  * Magento
  *
  * NOTICE OF LICENSE ......
  -->
 <config>
     <global>
         <install>
             <date><![CDATA[Mon, 10 Jun 2013 16:34:40 +0000]]></date>
         </install>
         <crypt>
             <key><![CDATA[9a38bb0fba550a5d295b3789fe2dafee]]></key>
         </crypt>
         <disable_local_modules>false</disable_local_modules>
         <resources>
             <db>
                 <table_prefix><![CDATA[]]></table_prefix>
             </db>
             <default_setup>
                 <connection>
                     <host><![CDATA[localhost]]></host>
                     <username><![CDATA[usernamehere]]></username>
                     <password><![CDATA[passwordhere]]></password>
                     <dbname><![CDATA[dbnamehere]]></dbname>
                     <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                     <model><![CDATA[mysql4]]></model>
                     <type><![CDATA[pdo_mysql]]></type>
                     <pdoType><![CDATA[]]></pdoType>
                     <active>1</active>
                 </connection>
             </default_setup>
         </resources>
         <session_save><![CDATA[files]]></session_save>
     </global>
     <admin>
         <routers>
             <adminhtml>
                 <args>
                     <frontName><![CDATA[admin]]></frontName>
                 </args>
             </adminhtml>
         </routers>
     </admin>
 </config>

No correct solution

OTHER TIPS

Let's try to debug together. In Mage.php file line 766

$localConfigFile = $etcDir . DS . 'local.xml';

    if (is_readable($localConfigFile)) {
        $localConfig = simplexml_load_file($localConfigFile);
        date_default_timezone_set('UTC');
        if (($date = $localConfig->global->install->date) && strtotime($date)) {
            self::$_isInstalled = true;
        }
    }

So what Magento tries to do here is to load app/etc/local.xml

My guess would be that when you change your DB name/username/password you saved the file incorrectly (some editors add BOM signature). The local.xml file should be saved UTF8 without BOM option.

many time this problem occuer from file permission

so please set proper file permission for more info

http://www.magentocommerce.com/wiki/groups/227/cache_is_not_writable

enable error reporting and try to create log file

Mage::log('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);

Also one more reason of header already sent

In index.php added any echo then show error and in var/reports showing header already sent error

please check index.php if added any echo then remove it

Yes, the problem for that error is only "]" for current issue. Try to check your new host detail, user name and password. Also, correct way to add.

There has been an error processing your request

Cannot send headers; headers already sent in /var/www/leaveasy.com/Leaveasy/app/Mage.php, line 767:

Trace:

#0 /var/www/leaveasy.com/Leaveasy/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /var/www/leaveasy.com/Leaveasy/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...')
#2 /var/www/leaveasy.com/Leaveasy/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse()
#3 /var/www/leaveasy.com/Leaveasy/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(202): Mage_Core_Controller_Varien_Front->getResponse()
#4 /var/www/leaveasy.com/Leaveasy/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#5 /var/www/leaveasy.com/Leaveasy/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /var/www/leaveasy.com/Leaveasy/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#7 /var/www/leaveasy.com/Leaveasy/index.php(89): Mage::run('', 'store')
#8 {main}

Error log record number: 724004798

I recently encountered this problem, and I was able to fix it myself. I reviewed my local.xml, and found out an extra character å character, because I accidentally entered and saved it when I pressed OPTION + A in my keyboard, instead of CONTROL + A. :)

this can happen for several reasons. To find out wich of those reason is the one affecting you, follow these instructions:

Instead of opening your page in the browser, run in the commandline:

curl http://yourpage.com/

you will get the error and/or data that is being written before the headers can be send.

Example, I got this:

<br />
<b>Warning</b>:  file_put_contents(/var/www/html/var/log/system.log): failed to open stream: Permission denied in <b>/var/www/html/app/Mage.php</b> on line <b>832</b><br />
<br />
<b>Warning</b>:  chmod(): Permission denied in <b>/var/www/html/app/Mage.php</b> on line <b>833</b><br />
<script type="text/javascript">window.location.href = 'http://bluepowershop.localhost/errors/report.php?id=629963827323&skin=default';</script>

that means I have to setup my permissions for var/log files to be writtable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top