skip to content

System: HTTP Server Status Codes

A lot of people get confused when they start looking at raw log files. This is probably because they were never designed to be read by humans. The page focuses on one component of the log file - the Status Code.

Status Codes

The codes can be broken up into: successful response (codes beginning in 2), a redirection (codes beginning in 3), an error caused by the client (codes beginning in 4), or an error in the server (codes beginning in 5).

The specific meanings of the most commonly encountered codes are presented below:

200 - OK
indicates a successful request resulting in a file being returned.
206 - Partial Content
indicates that a file was only partially downloaded. The download could have been interrupted by someone leaving the page before it's fully loaded (in the case of embedded images) or cancelling a download (in the case of PDF, MP3 and similar file types).
301 - Moved Permanently
the server has indicated that the requested file is now located at a new address. Search engines should update their index by removing the old address and replacing it (PR intact) with the new one.
302 - Found
the user has been redirected, but as it's not a Permanent redirect no further action needs to be taken. This could be as simple as the server adding a / to the end of the request, or the result of a header command in PHP.
304 - Not Modified
an intelligent user agent (browser) has made a request for a file which is already present in its cache. A 304 indicates that the cached version has the same timestamp as the 'live' version of the file so they don't need to download it. If the 'live' file was newer then the response would instead be a 200.
400 - Bad Request
the server couldn't make sense of the request.
401 - Unauthorised (password required)
an attempt has been made to access a directory or file that requires authentication (username and password). Subsequent requests would normally contain a username and password, resulting in either a 200 (user has been authenticated) or 401 (authentication failed).
403 - Forbidden
the server has blocked access to a directory or file. This typically applies to requests that would otherwise result in a directory listing being displayed.
404 - Not Found
the requested file does not exist on the server. This normally indicates a broken link (internal or external).
408 - Request Timeout
the client/server connection process was so slow that the server decided to 'hang up'.
410 - Gone
the server has indicated that the requested file used to exist but has now been permanently removed. Search engines should remove the address from their index
414 - Request-URI Too Long
the request was too long. This normally indicates an attempt to compromise the server using a buffer overflow exploit.

For more on log file formats and analysing them using command-line tools, refer to the article Analyzing Apache Log Files.


< System

User Comments

Post your comment or question

11 July, 2014

I need help ,,, where can i find that script,,

17 May, 2013

I have task to write a script to do the following:

Apache log-file (access_log). Using standard command-line tools, parse the file to produce the following:

  • The top 10 IPs making the most requests, displaying the IP address and number of requests made
  • Who is the owner of each of these IPs
  • Top 10 requested pages and the number of requests made for each
  • Percentage of successful requests
  • Percentage of unsuccessful requests
  • Top unsuccessful page requests
  • The total number of requests made every minute in the time period covered
  • For each of the top 10 IPs, show the top 5 pages requested and the number of requests for each

Your first priority should be getting correct answers to these questions, as if you were gathering them to diagnose and fix an ongoing critical issue.

For bonus points, please explain what you think is going on in this log-file.

For extra bonus points, generate an ASCII bar-chart showing the number of requests per minute

For super extra bonus points, write a script that would do this every hour and generate a html report.