Many of us have at some point come across the dreaded Internal Server Error 500 message while routinely visiting random web sites.
For web site visitors, it can be a frustrating experience, especially if the error is occurring on a page one needs to access to obtain important information. For system administrators, this error is even more frustrating as there is no universal solution to the problem.
Given that SugarCRM is also a web based system, it should be no surprise that it is possible to experience similar errors while using it. Before we get into some of the potential sources of this error, let us take a moment to discuss some items you can quickly cross off your list as potential sources:
1. The web browser. When an error 500 is encountered, it will manifest itself in the same manner on all browsers, whether it be Firefox, Chrome, Internet Explorer, etc. This is because it is a server side problem, thus there is no need to test different browsers.
2. The operating system. As described in the previous point, it is a server side problem. As a result, changes in either the browser or operating system at the end user side will not help alleviate the problem.
Now, let us explore some potential causes for this error.
Although the error itself is not very informative, it does at least tell us that the problem is at the server, not the client. In the case of SugarCRM, this usually leads us to the conclusion that a bit of code in one of its source PHP files could not be parsed or did not execute. Under normal circumstances, one would not be modifying said files and the problem is indeed often times rooted in a customization.
Some common causes for such errors include:
A. Unbalanced brackets, parentheses, or braces within a code file.
//Execute some code
Note the missing ending brace symbol needed to close off the IF statement. Take a look at your logic hooks, custom controllers and similar customizations and supporting files for potential syntax errors of this type and correct as necessary.
B. Using echo to output data from an array.
$myArray = array("a", "b", "c");
This too is not permissible, but again, the error message does not really point us to this being its cause. As with point A above, examine your customization files for potential problems.
C. Endless loops. Take a look at your logic hooks and other custom code files. Ensure that all loops that they may contain have some method for terminating. If they do not, the endless loop will eventually consume as much memory as it can and crash. Sometimes even crashing the entire web server.
D. Improper PHP settings. Some PHP settings can also cause problems, as described in a previous post.
PHP settings are always worth a look as one can never be too sure that they are not causing problems, even though SugarCRM may appear to function correctly. For example, all features work, but specific tasks that require more memory/execution time, such as installing a module or performing a Mass Update may generate errors.
E. SugarCRM bug. Older versions of SugarCRM (early 6.3 series) had a problem where the Uservardefs.php file in cache/modules/Users would not get created correctly by SugarCRM and cause error 500 messages. To resolve the problem, upgrade your SugarCRM system. Alternatively, make the Uservardefs.php file read-only once you have a good copy of it so as to prevent SugarCRM from potentially recreating a bad version. A good copy can be obtained by forcing SugarCRM to re-create the file by means of a simple deletion of the file. Once a good copy is created, the error 500 messages will immediately disappear.
F. Permissions. Improper permissions can generate error 500 messages. Some common scenarios are: limited permissions to the cache or custom directories, .htaccess settings limiting PHP execution and other.
In summary, unless you are making customizations to core code files, error 500 messages during SugarCRM usage are likely the result of either custom code or PHP/server configuration.