Skip to content

HTTP status codes#

So we've fetched information from the remote web server and we've even sent some too. That's been fun to see in action but what if you request something from a web server that doesn't exist? What happens if you ask for a file, say an image, that isn't there?

You get an HTTP 404 Not Found status code.

The HTTP protocol has a lot of status code. Not a crazy amount, but enough that you'll want to only really remember a few of the important ones. That being said here's a link to all of the current codes: https://www.iana.org/assignments/http-status-codes/http-status-codes.txt.

Let's look at a few important notes.

Firstly, look at this part of the above link:

1
2
3
4
5
1xx: Informational - Request received, continuing process
2xx: Success - The action was successfully received, understood, and accepted
3xx: Redirection - Further action must be taken in order to complete the request
4xx: Client Error - The request contains bad syntax or cannot be fulfilled
5xx: Server Error - The server failed to fulfill an apparently valid request

HTTP status codes, as you can see, are numbers. They start with (at the time of writing): 1, 2, 3, 4, and 5. Each are three digits long. The starting digit decides what the code is going to be for, as shown below:

Status Code Meaning
1xx Informational - Request received, continuing process
2xx Success - The action was successfully received, understood, and accepted
3xx Redirection - Further action must be taken in order to complete the request
4xx Client Error - The request contains bad syntax or cannot be fulfilled
5xx Server Error - The server failed to fulfill an apparently valid request

You may already actually know of a very common HTTP Status Code: 404 Not Found.

Here are the most common status codes you'll see:

  • 200 OK
  • 301 Moved Permanently
  • 302 Found
  • 303 See other
  • 401 Unauthorised
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed ("Method" referring, of course, to the HTTP method GET, POST, etc.)
  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout

All the codes will be around, but they're nowhere near as common as the above codes.