Is your Drupal site showing “500 Internal Server Error” all of a sudden?
In our role as Support Engineers for web hosts, this is a common error we see in Drual websites.
We’ve seen this happen during:
- Drupal core update,
- Module or Theme update,
- Website feature additions (code update),
- PHP upgrade or reconfiguration,
- Web server (eg. Apache) updates,
- Website migration, or
- New website setup
What is Drupal 500 internal server error?
500 Internal Server Error is a web server’s way of saying, “Something has gone wrong when I tried to display the page. Not sure what.”
Almost always it means that there is a configuration error in either the web server settings, PHP settings or website settings.
Some of these errors are temporary (eg. due to resource limits), and might go away when you refresh the site.
But if it doesn’t, it might indeed be a server issue.
How to troubleshoot Drupal error 500
The standard way to troubleshoot error 500 is to analyze the web server log files.
An error log might look something like this:
[Thu Jul 19 11:01:33.126782 2018] [:error] [pid 31931] [client xx.xx.xx.xx] PHP Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 17120 bytes) in /var/www/drupal7/includes/module.inc on line 503
It won’t make much sense if you aren’t a developer.
So, let’s see what else can be done.
Troubleshooting using error display in Drupal
All web hosts supress PHP errors by default.
So, when there’s an Error 500, you’re not likely to see the reason on the site.
However, you can enable error reporting by adding these lines in index.php.
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
And when the page is refreshed, you may see an error such as this:
PHP Fatal error: require_once(): Failed opening required '/home/username/sitename/docroot/sites/all/modules/contrib/rules_dev_comments/includes/rules_dev_comments.plugin.inc' (include_path='.:/usr/share/php:/usr/share/pear') in /home/username/sitename/docroot/includes/bootstrap.inc on line 3157
Again, that one can also be a bit difficult to understand if you aren’t a Drupal developer.
Drupal error 500 troubleshooting for humans
For those who do not want a PhD in Drupal, and wants this error fixed, we’ll list here the most common causes for this error, and how to fix them.
1. Misconfigured .htaccess
The number one reason we’ve seen for this error is incompatibility of .htaccess settings with the server environment.
Some hosting accounts will be set to single site environment, while others will be set to multi-site.
Some will allow directory listing and soft links, while others may not.
But Drupal packages and installation instructions assume a basic set of hosting settings to be present.
We’ve seen enabling or disabling these settings (differs from one server to another) can fix this error:
- RewriteBase /
- Options -Multiviews
- Options +FollowSymLinks
- Options -Indexes
Comment (by adding a #) or uncomment these settings one by one to see if it’ll clear the error.
If it is an error with .htaccess, that should fix it.
2. PHP configuration errors
The next big source of error is PHP config issues.
We’ve seen this range from un-installed PHP extensions & wrong PHP paths to incorrect PHP.ini & obsolete PHP handlers.
By default, Drupal requires these PHP extensions to function, but misconfigurations can prevent access to these libraries.
- OpenSSL
- Curl
- GD
- PDO
- XML
- JSON
- Mbstring
In addition to these modules, PHP also requires certain PHP settings to be set right.
For eg. “allow_url_fopen”, “magic_quotes_gpc”, and “register_globals” needs to be set to “off”.
We’ve seen cases where this is either not set right, or the website uses an incorrect version of php.ini, that had the settings configured wrong.
To fix this, we use a two step method:
- Verify PHP config path – We check if the PHP handler, PHP program file, and the PHP configuration file are all set correctly.
- Verify PHP settings – We then look at the settings to make sure everything is as per Drupal’s requirement doc.
The list of individual specs are a bit too long for this article. However, if you need help fixing your site, click here to talk to our Drupal experts.
3. Resource limits
In VPS and Shared hosting servers, a big cause of errors is the memory limit.
Drupal core only requires 32 MB of memory to execute, and most hosting accounts provide a minimum of 128 MB or 256 MB of memory for Drupal processes.
However, when modules are added, the memory requirement of Drupal processes can exceed the allocated quota. The operating system will kill such processes, and the visitor gets a 500 error.
Here’s one way that we’ve seen to be working for many:
- Login to your FTP account.
- Download .htaccess file.
- Add the line
php_value memory_limit 512M
in the file, and save - Re-upload the file.
If you are not sure how to do this, or if editing is disallowed in your account, our Prestashop experts can help you fix this. Click here to submit a support request. We are online 24/7.
4. File ownership or permission errors
Site migrations or new site setup can be hard.
A lot of settings need to be changed to make an app compatible to the new environment.
We’ve seen file and folder permissions set wrong in Drupal installations, causing the PHP execution to fail.
The right permissions for files is 644 and folders is 755.
If you see anywhere in the log files that the permissions (user, group, world) is not set right, these commands could help:
find /home/USERNAME/public_html -type d -exec chmod 755 {} \;
find /home/USERNAME/public_html -type f -exec chmod 644 {} \;
Replace /home/USERNAME/public_html
with the path to your web directory.
You might also do this from an admin front-end (if you are provided with one).
Warning : Take a backup of your site before you execute any command.
If you are not sure how to reset the file and folder permissions, click here to request support. Our Drupal experts are online 24/7.
5. Errors in Drupal modules or themes
Not all modules are created equal.
Some have code errors, like a missing “;” or a wrong module path.
We’ve seen Drupal sites go down after an upgrade, or a code update, or a backup restore.
In such cases, you can disable the Drupal modules and themes one by one to find out which one caused the error.
A faster way is to analyze the log files and figure out the error’s origin. Here at Bobcares, that’s our favored method, and helps us resolve issues within minutes.
If you are in a hurry and need the issue resolved right now, click here to talk to our Drupal experts. We’re online 24/7.
6. Web server or FastCGI config issues
Many settings in webservers can conflict with each other.
For eg. since Apache 2.2, the config option “SymLinksIfOwnerMatch” is available that is more secure than the older “FollowSymLinks”.
We’ve seen sites where both these options are enabled in .htaccess, causing the site to fail.
This usually happens after a migration where the site owner tries to retain the old settings while adding the new ones.
Similarly, FastCGI has many limits such as Process Execution Time, Request Length, etc. which we’ve found to limit Drupal execution.
In such cases, there are no cookie-cutter solutions. We follow the log trail, find out what the conflicts are, and fix the offending setting.
7. Stale cache, security settings, and others
Temporary issues like resource bottlenecks or server load can cause Drupal error 500.
But the Drupal or server cache will store them for a while more even after the error has passed.
So, in many cases, we’ve solved the issue just by clearing the cache.
Similarly, we’ve seen this error displayed when a script execution is blocked by a firewall such as mod_security.
In such cases, we identify which exact security rule is being triggered and add an exemption for that site.
More causes for Drupal error 500
There can be way more reasons such as Database errors, Brute force attacks, etc. for this error to happen.
If none of the above could help you fix this error, you’ll need to get a Drupal expert to look into this issue.
Here at Bobcares, we resolve hundreds of these issues everyday in our role of Support Engineers for web hosts, and other online companies.
We should be able to fix this error for you fairly quickly. Click here to submit a support request. We’re online 24/7.
Conclusion
Drupal 500 internal server error is caused by resource limits, PHP misconfiguration, .htaccess errors, and more. Here we’ve gone through the top 7 reasons for this error and how our Support Engineers fix it for web hosting providers.
13 августа 2013 в 20:20
Доброго времени суток! Спустя несколько дней после установки Drupal и несольких модулей, я вдруг получил ошибку 500 Internal Server Error. Ни в какие php скрипты не залезал, ничего кроме модулей не устанавливал. Хочу отметить, что облазил весь интернет на руссском и английском. Спрашивал у хостинг-провайдера, выяснилось, что ошибка в файле .htaccess (точно), но решить ее не могут. Вот логи ошибки, если помогут (error_log): PHP Fatal error: Call to undefined function menu_load() in …/public_html/includes/menu.inc on line 579(593) ; Прошу Вашей помощи, Друзья! Спасибо!
- Drupal7
- Есть вопрос
- Решение проблем
By RobOnema on
Hello,
I have a problem with the Drupal 6 installation.
Settings:
Version Apache : Apache/2.2.22
Version MySQL : mysql Ver 14.14 Distrib 5.5.28
Version PHP 5.2.17
I try to install Drupal as usual (copy default.settings.php -> settings.php…).
Then I go to «http://localhost» with my browser to set up the installation.
But at the database configuration, when I confirm my settings, I have the HTTP 500 Internal server error.
If I refresh the page, I can still continue the installation until I finish it.
The problem now comes when I try to go to admin pages like modules. I can’t access to these pages and I got once more the HTTP 500 Internal server error. But the weird thing is that I can still go to create contents pages and add contents : and it works !
I have checked the error.log of Apache and this is what I got:
[Fri Jun 26 17:05:40 2015] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Fri Jun 26 17:05:40 2015] [notice] Child 1164: Exit event signaled. Child process is ending.
[Fri Jun 26 17:05:41 2015] [notice] Child 1164: Released the start mutex
[Fri Jun 26 17:05:42 2015] [notice] Child 1164: All worker threads have exited.
[Fri Jun 26 17:05:42 2015] [notice] Child 1164: Child process is exiting
[Fri Jun 26 17:05:42 2015] [notice] Parent: Child process exited successfully.
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_pdo_mysql.dll' - Le module sp\xe9cifi\xe9 est introuvable.\r\n in Unknown on line 0
[Fri Jun 26 17:05:50 2015] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Fri Jun 26 17:05:50 2015] [notice] Server built: Jul 10 2013 01:52:12
[Fri Jun 26 17:05:50 2015] [notice] Parent: Created child process 1944
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_pdo_mysql.dll' - Le module sp\xe9cifi\xe9 est introuvable.\r\n in Unknown on line 0
[Fri Jun 26 17:05:50 2015] [notice] Child 1944: Child process is running
[Fri Jun 26 17:05:50 2015] [notice] Child 1944: Acquired the start mutex.
[Fri Jun 26 17:05:50 2015] [notice] Child 1944: Starting 64 worker threads.
[Fri Jun 26 17:05:50 2015] [notice] Child 1944: Starting thread to listen on port 80.
sp\xe9cifi\xe9 module is not found.
So I checked that the file ‘C:\Program Files (x86)\PHP\ext\php_pdo_mysql.dll’ and it is indeed here.
In my php.ini file, ‘extension=php_pdo_mysql.dll’ is not in comment.
I can’t find the solution to my problem. If someone has the solution or can help me.
Thank you so much.
Drupal 500 Internal Server Error – Top 5 Causes and How to Fix Them
24 May 2021
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!
After using drush up
on my drupal installation to update from drupal version 7.34 to drupal 7.35, I get Internal Server Error 500.
I have moved away .htaccess file and move it back without any result.
I have uploaded /overwritten the files with the ones downloaded for 7.35 without any result.
I have deleted everything from my server except for sites/* and themes/* and re-uploaded without any result.
I am running out of ideas. Please help!
P.S. Other websites on the same server still work properly so the server itself is not causing the issue.
P.P.S. I have also updated Ctools — From Chaos tools 7.x-1.6 to 7.x-1.7 in the same time.
asked Mar 19, 2015 at 20:35
Angelin CaluAngelin Calu
1,9058 gold badges24 silver badges45 bronze badges
In my case was not a .htaccess file error. Drush makes also backups when updating, and after the error I have copied back all the old overwritten files and I still got the error.
Drush messes some file write permissions so, the problem was actually fixed by changing the permissions for index.php from 664 to 644. (Grup write permission has to be off and for some reason drush changes that when updating).
answered Mar 21, 2015 at 13:04
Angelin CaluAngelin Calu
1,9058 gold badges24 silver badges45 bronze badges
This just happened to me as well, and it turns out it was a file/folder ownership problem, which drush does not account for. I ran ‘drush up drupal’ with the root user; however, the server was set up to need the specific user for that directory set to the owner. Running drush up with the root user had changed some key files/folders ownerships.
In my case, all owner/groups had been set to ‘root’, which caused the 500 error. In filezilla you can see the owner/group of each file/folder in the far right column. If these are set to root, you need to change them back to the correct owner — I used ssh and did the following command on the drupal root folder for the site:
chown -R CORRECTUSER:CORRECTUSER DRUPALROOTFOLDER
Not sure if this is your issue, but hopefully it helps someone.
answered Apr 1, 2015 at 17:30
I received an Internal Server Error as well after a Drush update. Changing file permissions on the index.php file from 664 to 644 fixed my issue.
answered Apr 3, 2018 at 3:03
1