Are you getting the “500 Internal Server Error” from your Drupal site all of a sudden? Well, don't you worry, as in this article I'll list one of the most common reasons why this error happens, so what are we waiting for? Let's roll.
Before I get into the reasons, let's first understand what this error really is? Well, basically it's a way of webserver saying, “Something has gone wrong when I tried to display the page. But I am not really sure what.” Most of the time it means that there is a configuration error with the settings of your web server, PHP, or website.
So, now with that out of our way, lets get down to the reasons and how you can resolve them (almost anyone will be able to do it, you don't necessarily have to be a Drupal developer).
Misconfigured .htaccess
One of the primary reasons why you'd get a Drupal “500 Internal Server Error” is because your .htaccess settings are not compatible with the server environment. You could try your luck by commenting (by adding a #) or uncommenting the following lines of code in the .htaccess file: RewriteBase /
Options -Multiviews
Options +FollowSymLinks
Options -Indexes
If the issue is with .htaccess, that should fix it.
Resource limits
Memory limit causes all sorts of different errors in VPS and Shared hosting servers. A minimum memory of 128 or 256 MB is provided by most hosting accounts for Drupal processes while only 32 MB of memory is required to execute Drupal core.
Now, all this is fine, but when contributed or custom modules are installed, the memory requirement of Drupal processes can exceed whatever quota is allocated to it. Thus the OS will kill such processes, and you will get a “500 Internal Server Error”.
Now, to fix this issue you will have to again open up the .htaccess file and add the following line to it:
php_value memory_limit 512M
File ownership or permission errors
Whether you are migrating an existing site from one Drupal version to another or setting up a new site altogether, we all know it's a pretty hard ride. As lots of settings need to be changed to make the site compatible to the new environment. One reason the “500 Internal Server Error” may occur is that the file and folder permissions are not set right in Drupal installations, thus causing the PHP execution to fail.
So, make sure that all the files have permissions set as 644 and the folders as 755.
Errors in Drupal modules or themes
At times for certain reasons some module or theme after getting updated or any other reasons might have some code that conflicts with the existing site’s code due to which the site starts showing the “500 Internal Server Error.”
So, what you should do then is trying disabling the modules and themes one by one to find out which one caused the error.
Stale cache
The “500 Internal Server Error” can also be caused by resource bottlenecks, server load or other such temporary issues. But the Drupal or server cache will store them for a while more even after the error has passed. You will easily be able to solve this issue by just clearing the cache.
Conclusion
These are the most common reasons (according to me) that can cause the Drupal “500 Internal Server Error,” but these are not the only ones as there can be many many more. So, if you find any new one, please mention it in the comments along with the solution. Thank you for reading!
Jibran Ullah
Sr. Drupal site Builder/ Drupal Themer/Drupal Module Developer