HTTP ERROR 500
When trying to access your website, you may see a page which returns the status code “500”. In Google Chrome, you’ll see a page with the error code
HTTP ERROR 500.
There are typically two reasons which can cause this error:
- The PHP code has crashed.
- The .htaccess file contains invalid rules.
Here are some things you can try to debug and fix this.
Fixing crashing PHP code
A HTTP ERROR 500 simply tells you that the PHP code has crashed, but gives no information as to why it has crashed.
Getting the real error message
To help fix this, you’ll first want to enable error messages on your website. You can enable PHP error messages from the control panel:
- Login to your control panel.
- Go to PHP Config.
- Select the domain name you are trying to debug and click Alter PHP Directives.
- Set “Display Errors” to “On” and click the Alter PHP Directives to save.
If you refresh the page, you should hopefully see an error message.
If don’t see an error message, this is likely caused by your script suppressing or capturing error messages from PHP.
The first thing to try is to see if your software has a debug mode option, log file or other setting which can be used to get the error message.
For example, WordPress has a setting
WP_DEBUG which can be used to show the actual error message. You can learn more about that option in the WordPress knowledge base: https://wordpress.org/support/article/debugging-in-wordpress/
If your software doesn’t have any way to see the PHP errors, it is likely that error message suppression was hard-coded into the application. If you check the PHP code, you will probably see lines like these:
ini_set('display_errors', 0); ini_set('display_startup_errors', 0); error_reporting(0);
Commenting out lines like these should enable the PHP error messages.
If this still doesn’t allow you to see any error messages, please contact the script developers for help.
Fixing the real error
If you’ve completed the steps above and have an actual error message, the next step is to fix it.
Unfortunately, there is no standard process to follow to fix such errors.
A good place to start would be to take a good look at the path of the file where the error occurs. Does it refer to a specific plugin or theme? If so, you can try to disable that plugin or theme and see if that removed the error. Reinstalling or upgrading the plugin, script or theme might help too.
Another good step is to search the web for your error message, in combination with the script, plugin or theme which is generating this error message. Maybe there are other people who’ve had the same error, and have already found and described a solution.
If you’re unable to find anything, you can ask a question somewhere about the error. You could check the support channel of the plugin or theme causing the issue, ask your question on a general programming forum like StackOverflow, or ask it on the InfinityFree forum in the Website Development category.
Fixing invalid .htaccess rules
If your .htaccess file has an error, this may cause a HTTP ERROR 500 too. Unfortunately, there is no way to get an actual error message in this case.
However, you can remove or rename your .htaccess file (to
.htaccess.backup, for example) and refresh the page. If you don’t see the HTTP ERROR 500 anymore, that likely means there was an error in the .htaccess file.
The simplest way to try to fix this is to download a fresh copy of the .htaccess file of your software and use it to replace your current .htaccess file. Doing so hopefully removes any broken lines.
If that’s not an option, you can restore your .htaccess file, and try to figure out which line or lines are causing the issue.
A fairly efficient way to do so is by doing a “binary search”. This means you first comment out about half of the lines in the .htaccess file and see if you still get the error. For example, if you comment out the bottom half and your website works, but you comment out the top half (and uncomment the bottom half) and your website breaks, you know that the bottom half of the code contains the broken line. You can then repeat this by commenting out a quarter of the code, or half of the broken half, to narrow down the error even further. You can repeat these steps until you’ve narrowed it down to a small block or even an individual line of code.
You can then attempt to remove or fix the broken lines specifically. If you’re not sure how, you can ask a question somewhere about the error. You could check the support channel of the plugin or theme causing the issue, ask your question on a general programming forum like StackOverflow, or ask it on our forum in the Website Development category.