The HTTP Internal Server Error 500 typically occurs when the server encounters an unexpected condition that prevents it from fulfilling the request. This post will help you understand the causes of the error and find appropriate solutions.
It is considered a general error on the server side due to a non-specified problem. According to the RFC Standards, the definition is as follows:
The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
This is not an error in your connection or browser; rather, it indicates an issue on the website’s end.
Generic Error 500 in Chrome browser
The White Screen of Death of Error 500
The “White Screen of Death” (WSOD) is a term used to describe the 500 HTTP error, and other 5XX HTTP error codes when the server cannot serve any content to the user. Some browsers like Safari or Firefox present this white screen:
Firefox does not show 500 error messages
Alternatively, you have browsers that translate the Internal 500 error, showing different informative messages.
Different 500 Error Messages
Although this error may appear in many ways, they all mean the same. The following displays a few examples of how you might see a 500 HTTP error.
“500 – Internal Server Error”
“500 Error”
“500 Internal Server Error. Sorry, something went wrong.”
“500 Internal Server Error”
“500. That’s an error. There was an error. Please try again later. That’s all we know.”
“HTTP 500 – Internal Server Error”
“HTTP 500”
“HTTP Error 500”
“Internal Server Error”
“This page isn’t working at the moment. HTTP ERROR 500.”
“This page isn’t working. – localhost is currently unable to handle this request. – HTTP ERROR 500”
Generic Error 500 shown in Edge browser
When the option to display errors to the user is enabled, and the execution is not interrupted, the server can provide more comprehensive information about errors than when the user encounters a WSOD (White Screen Of Death).
In such cases, the server may display crucial details related to the error, like the file and line number where the error occurred, a description of the error, and sometimes a stack trace.
The following screenshot shows an example of this, detailing a 500 internal server error on a WordPress page:
In the following section, you will come across various scenarios that can lead to the occurrence of the 500 error.
500 Internal Server Error Causes
A Database error while trying to retrieve data. E.g a corrupted Database, or a wrong SQL syntax.
The application throws an error, such as a runtime error, e.g. an insufficient PHP memory, or a PHP execution timeout.
There is an error in the application code. For instance, PHP is trying to include a nonexisting file, or a division by zero is interrupting the execution.
Your server hardware could have a problem. For instance, you have corrupted files due to a disk failure.
There is a server software problem. For instance, php-fpm is misconfigured or your current version has a bug.
How To Fix The 500 Internal Error
As previously mentioned, the reasons for a 500 error are varied and might not be immediately obvious in the browser.
To solve it, check the error logs or print them in the browser for further diagnosis.
When it comes to 500 Internal Server Errors, there’s no one-size-fits-all solution.
Checking error logs can help identify the root cause.
How To Get More Details About The Errors In PHP
The answer is simple: display the errors or inspect the logs. The latter option is preferable, as a 500 internal server error can sometimes cause the execution to break, resulting in nothing but a WSOD (White Screen Of Death).
Hey, just a heads up!
If you have a WordPress website hosted on a Wetopi server, you can easily access your logs with just a click of your mouse.
To enable logs, you have two options: one for generic PHP applications, and another for WordPress sites.
How to show and log errors in plain PHP applications
Enable error reporting: add the following line to the beginning of your PHP script:
Additonally, you can also set these directives in the PHP configuration file php.ini
error_reporting = E_ALL
display_errors = On
log_errors = On
error_log = /path/to/php_errors.log
How to show PHP errors in WordPress
You can use the WP_DEBUG constant in the wp-config.php file.This will enable debug mode in WordPress and display all PHP Errors, Warnings, and Notices on the screen.
Locate the wp-config.php file: This file is in the root directory of your WordPress installation.
Open the wp-config.php file: You can open this file using a text editor such as Notepad, TextEdit, or Sublime Text.
Add the WP_DEBUG constant to display the errors: define('WP_DEBUG', true);
Alternatively, enable the debug logging to the /wp-content/debug.log with this next constant: define( 'WP_DEBUG_LOG', true );
When inspecting logs, ensure you’re looking in the right place
When a 500 internal server error occurs in PHP, it is categorized as an ‘Error’ level message, rather than a ‘Warning’ or ‘Notice.Therefore, when examining logs or debugging screens for troubleshooting purposes, focus exclusively on Errors and skip Warning and Notice messages.