CakePHP says An Internal Error Has Occurred.

Recently I had the wonderful experience of CakePHP informing me that “An Internal Error Has Occurred”, with no more indication of what the problem could be. After digging around the CakePHP code I quickly found out that this code is pretty much used for any 500 browser error.  So I started the process of elimination:

  1. The site was working correctly.  I know this because most pages on the site came up just fine.  The error was only on certain pages.
  2. It was not caused by the page not existing on the server.  The controller, action, and models were all named correctly.  I know this because the page was working correct a week ago, and because I did a sanity check to ensure nothing had changed in this area.
  3. I checked to ensure the .htaccess had not been deleted, changed, or renamed.  All was OK here.
  4. I checked the CakePHP logs.  These exist in the ‘app/tmp/logs/’ directory.  There were NO errors reported, and no debug entries as well.
  5. I checked the /var/log/messges’ and found no errors reported there.
  6. I checked the /var/apache2/{log_file_name}’ and found no errors there.

Everything should have been working, according to the settings and log files, so why was I still receiving this internal error message?

How I solved it:

Finally, I got tired of playing around and simply edited the CakePHP code to output $params array to see the raw reason for the error.  I did this by editing the ‘cake/libs/error.php’ file and adding the following around line 176 in the “error500” function as the first two lines as follows:


This gave me a simple array that clearly informed me I was missing a table in the DB that was deprecated. From there I quickly found the entry in the model that was still trying to link to the deprecated table. I cleaned up the offending model, and now all is well with the world again.

, ,

17 responses to “CakePHP says An Internal Error Has Occurred.”

  1. In your CakePHP app in the ‘config’ folder change the following setting in the ‘core.php’ file

    Configure::write(‘debug’, 0);

    Change the ‘0’ value to a ‘2’ and CakePHP will print all debug errors. I’m going to use your method, however, to see if I can alter the layout of the Internal Server Error page. Thanks for the post!!

  2. Thanks Ed. I do not remember for sure if I change the debug level or not, but am pretty sure I did and it did not change the output.

  3. I wanted to add that I experienced this problem, and error.php was also reporting that it was a problem with a table. Except that my table existed. The cause of the problem was old cache files for the models in the CakePHP temp folder. Make sure you delete those when you change your database schema.

  4. Can confirm I had the same problem as Mat. It was old model cache files. Just delete all in /app/tmp/cache/models

  5. You can also change the app/config/core.php and change the debug to 2 …. It will give you more information there.

  6. Yes,
    I also faced similar problem of Internal Error Occured…
    But the cause was not missing table instead I was missing any field in my table assigned as primary key.

  7. Hi.
    Thanx so many much!
    I lost to check my log file. after read here I went there and saw I have many errors in my CACHE configs.
    now I disable all caches and don’t have any problem,
    and now I’m fixing those confs.
    thanx again,

  8. i have same problem and i put this print_r($params);
    die(); in error_500 and i show nothing in it.. it gives me blank when i make it in popup .please help me to get out of it. thank you.