What is a 500 internal server error?
A 500 internal server error indicates that your website currently has an error and cannot be loaded. In this case it often means that there is a problem in a script that the website needs to display.
The server where your website is hosted executes the scripts you have made and expects the result to be passed on to your browser. Your browser then displays the result and in most cases that is your website. If, for example, there is a typo in your script, the server cannot execute the script and therefore your browser cannot display the website. The server realizes that it cannot show a result to your browser and catches it with a server error. In this case, your browser displays an internal server error with a certain status code, for example 500. This is also called an HTTP status code.
All server error http status codes
- 500: Internal Server Error
- 501: Not Implemented
- 502: Bad Gateway
- 503: Service not available
- 504: Gateway Timeout
- 505: HTTP Version Not Supported
- 509: Bandwidth exceeded (unofficial HTTP status code)
- 510: Not renewed
- 511: Network Authentication Required
- 521: Web server is down (Cloudflare only)
- 522: Connection taking too long (Only at Cloudflare)
- 523: Source is unreachable (Only at Cloudflare)
- 525: SSL handshake fails (Only at Cloudflare)
How do I solve a 500 internal server error?
Solve 500 internal server error in 3 steps
View the log file
First of all, it is important to know what the exact problem is, what caused the problem and in which file the problem is located.
This is a file where all requests, warnings and errors are written to.
Often the requests are in the file called access.log or access_log. The warnings and errors are often in the error.log or error_log. There will undoubtedly be several variants of the log name, but often the title will contain the subject you are looking for!
In this article I have listed an error in a php script as an example from our log below:
Mon Aug 04 12:51:07.885464 2016] [lsapi:error] [pid 89667:tid 139625036830464] [client 89.205.137.188:38415] [host 1.2.3.4] Backend fatal error: PHP Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)) in /var/www/html/phpinfo.php on line 2.
This log line tells us that something is wrong in the file /var/www/html/phpinfo.php on line number 4. Here you could possibly find the error that causes you to get the http 500 error when surfing to your domain name .
Open file with error
In this step, we’re going to open the file we just found, namely /var/www/html/phpinfo.php and see what it says on line number 2.
My example .php script
<?php
echo "hello world';
?>
Now that I have opened the file, I can actually see the error that occurs quite quickly.
You see that I use the function echo to print the text “hello world” on the screen. This echo function requires you to enclose the text in double quotes, but as you can see I open the function with double quotes, but close it with single quotes.
Fixing the Error
Now that I’ve found the error, I’m going to modify the script and fix the error. So I modify the php script to the following script:
<?php
echo "hello world";
?>
I save the script and visit the domain name where I uploaded my script. If all went well, you should now see the text : “hello world” appear on the screen and you do not have a new line in your log file.
This means that you solved your http 500 error all by yourself and your website should be fully functional again!
wordpress 500 internal server error?
Since WordPress is the most widely used CMS worldwide, HTTP 500 error is also often found here (unfortunately).
Fortunately, because there are so many WordPress websites online and created, there is also a huge amount to be found about the 500 errors and you can often quite easily apply a solution to your WordPress website.
To help you too, I’ve put together some steps that you should always try first before looking further on the Internet or within your website.
WordPress error 500 fix step-by-step plan!
Below I have created a roadmap that will help you easily and quickly fix the 500 error in WordPress. With this step-by-step plan you will always make sure that you find out the source of the problem so you can apply a good solution. You will also proceed systematically and avoid breaking more in your site than is already broken.
View logs
Look at the logs as described above and see if you can find an error message or a file/plugin/theme that is known to you.
Disable theme or plugin
Once you have found the error - often in a theme or plugin - disable this theme or plugin. If this still works through the WordPress backend, I recommend doing it there. If that no longer works, then the FTP is the place to change the folder of the theme or plugin to, for example, themename-old. This will prevent WordPress from finding the theme or plugin and disable it.
Check if WordPress website no longer has http 500 error
Once you have done this, visit your WordPress website and check if it is working again. Should the errors be gone, then you have fixed it. If there are still errors, check the log again and check if the error message has changed. There might be something else wrong and you can fix it by disabling the theme or plugin!
Sometimes it also pays to google the exact error message from the logs of your website that you checked in step 1.
For example, the error may be known on the Internet and you can easily fix it via an update or modification to the theme or plugin!
Just keep in mind that you always try to find out where the error / problem is via these steps first and only then start looking for a solution!