The first step in troubleshooting an HTTP server error is the 5xx Server Error message the failure generated. For many of the most common server errors, the code doesn't help much in hunting down the source of the problem. Fortunately, a handful of causes accounts for the bulk of 500 (generic), 503 (unavailable), and 520 (unknown) server-error messages.
When a server generates an error code in response to a request, there are a finite number of possible causes. The problem is that too often the HTTP error code doesn't provide much of a clue about the error's origin. A restart or some other short-term fix may get you running again, but some errors defy a quick solution. These are the most likely sources of server-error glitches whose causes aren't readily apparent: 500 (generic), 503 (unavailable), and 520 (unknown error).
W3Schools.com provides a complete list of HTTP status messages along with a brief description of each; 5xx server error messages and descriptions are shown below.
Of the many HTTP server error codes, the three that are most difficult to troubleshoot are 500 (generic), 503 (unavailable), and 520 (unknown error). Source: W3Schools.com
Getting to the Bottom of a '500 Internal Server Error' Message
About.com's Tim Fisher identifies the three most common causes of the generic 500 Internal Server Error alert:
- Permission errors caused by a file or folder lacking appropriate access rights. The incorrect permission is most often associated with a PHP or CGI script. The standard setting for such scripts is 0775 (-rwxr-xr-x).
- PHP timeouts when attempting to connect to external resources. These can usually be addressed by adjusting the timeout rules or improving the script's error handling.
- A .htaccess coding error.
Servers running Microsoft Internet Information Service generate more specific error codes. The Microsoft Support site provides a complete list of these supplemental codes, which are listed below.
HTTP status code in IIS 7.0, IIS 7.5, and IIS 8.0 for the generic 500 Internal server error. Source: Microsoft
Hunting Down the Source of 503 Server Unavailable Messages
Some server errors are a side-effect of HTTP showing its age. An example is described in a Stack Overflow post from June 2013. A 503 Service Unavailable error was traced to a User Agent header that lacked "Mozilla." A commenter noted that many mobile phones have User Agents that don't start with Mozilla.
An HTTP 503 Service Unavailable message was traced to a missing "Mozilla" User Agent. Source: Stack Overflow
The reason for using the Mozilla User Agent goes back to the 1990s and the first popular browsers: Mosaic and Netscape. Netscape differed from Mosaic in that it supported frames. Sites ultimately had a "frames" version and a "no frames" version, which were distinguished by the server via the User Agent. Ultimately, some servers were configured to drop any browser that didn't have the Mozilla User Agent, assuming that any such browser wouldn't render the page correctly.
Solving the Mystery of a 520 Unknown Error Message
When a server encounters something unexpected or unacceptable, such as a protocol violation or empty response, it may kick out a 520 Unknown Error message. In a June 6, 2015, article, CloudFlare's Michelle Zatlin identifies the five common causes of a 520 message:
- Connection resets occur after a successful TCP handshake.
- The header size limit is exceeded.
- The origin server returned an empty response.
- The HTTP response is invalid.
- The HTTP response is missing some headers.
Run a cURL command to determine whether the origin server is returning an empty reply, an invalid HTTP response, or over-large response headers, among other possible problems. For example, when the origin response is an empty reply, the cURL command returns an error message such as the one shown below.
The cURL command returns "Empty reply from server" in the 520 error message when the origin server returns an empty reply. Source: CloudFlare
The most efficient way to monitor the availability and performance of apps, databases, and systems is the Happy Apps service, which lets you create checks for the web, MySQL, MongoDB, Redis, Riak, and ElasticSearch. Happy Apps is a robust app-management solution that supports SSH and agent-based connectivity to all your apps on public, private, and hybrid clouds. The service provides dependency maps for determining the impact your IT systems will have on other apps.
All checks performed on your apps are collected in easy-to-read reports that can be analyzed to identify repeating patterns and performance glitches over time. If you're looking for ways to save time, trouble, and money when managing your apps, visit Happy Apps today.