When you access a website, and it displays Error Code 500, it means that it shows an HTTP status code for a problem with either your website or server and it can’t show you a more particular status report.
The error can be shown in a few different ways:
Internal Server Error
500 Error
HTTP Error 500
HTTP 500 Internal Server Error
HTTP status codes are standard response codes provided by web servers. Codes help us identify the cause of the problem when the web page does not load properly.
The term HTTP status code is the usual term for the HTTP status line that closes both the HTTP status code and the HTTP reason phrase. HTTP status codes are sometimes called browser error codes or Internet error codes. In our case, the HTTP 500 line is comprised of the HTTP 500 line and HTTP reason phrase: internal server error.
Here are some reasons why the Internal Server Error is shown and how we can prevent this:
1. PHP errors
The first thing you need to do is to check the error_log file in Apache or the web server you are currently using to learn more about the problem you are facing. If this is a PHP error, then it will be logged in the file error_log. Try to set ON display_errors in the php.ini file manually:
display_errors = On
To display all PHP errors, you can enable E_ALL in your scripts using the following PHP code:
error_reporting = E_ALL
2. Folder/file permissions are incorrect
Ensure that all folders in public_html have permissions set to either 755 or 644, and the public_html folder itself has the permissions set to 750. Also, all files in the public_html folder should have the permissions set to 644. Other non-standard permissions can cause errors and the website might not function correctly.
3. Wrong instructions in .htaccess
Make sure there are no incorrect or contradictory lines in the .htaccess file. The most effective way to debug this is to comment on the lines you are not sure if they are correctly written, in the .htaccess file by adding the “#” symbol at the beginning of the row. Error 500 might occur to hosting clients who have just installed new software on their hosting account, such as Joomla. So, for a website with Joomla in the .htaccess file, where Options + FollowSymLinks is listed, replace it with Options + SymLinksIfOwnerMatch for it to properly work.
4. You have exceeded the resources allocated to your hosting account
Error 500 can also occur when your hosting account uses more resources than it was allowed or consumed some monthly finite resources (bandwidth). Connecting through SSH access, type the ps aux command to view all processes running on your account. You can close any process by typing kill -9 processID. Be sure to replace the processID key with the process ID you want to close.
To identify the root cause of the error, log into the web hosting control panel, such as Cpanel. Once connected, click on the “Error Logs” icon in the logs section.
5. PHP syntax error
This doesn’t happen frequently, but we need to check if all other options failed. Search for a PHP syntax error in the file where the Internal Error 500 occurred, apply the split and search rule by commenting on the lines you suspect as the cause of the problem and see if the error disappears.
The rule of splitting and searching in reverse is to comment out the lines that might be causing issues, instead of deleting all the lines and putting them after the issue is fixed.