How to Decode a Cryptic Server Error Message
Got a nagging HTTP server error message that won't quit? Here are few tips for handling some of the frequent offenders: 500, 503, and 520 server error messages.
Join the DZone community and get the full member experience.Join For Free
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.
Published at DZone with permission of Darren Perucci, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.