Guide through HTTP codes

About HTTP codes

HTTP codes are extremely important notes of the servers that are added to the web pages, but are not an integral part. The server uses them to report us about the status of a visit to a site, or about the success of the visit.

HTTP status codes are like a short note from the web server that gets tacked onto the top of a web page ,and it’s not part of the web page. Instead, it’s a message from the server letting you know how things went when the request to view the page was received by the server. Messages are returned every time your browser interacts with the server and if we know HTTP status codes we can easily diagnosing and fixing errors on our website. There are about 40 unique server status codes, but the most common HTTP code is 404 and 301 errors. The following 5 classes of code and redirect are valuable.

Most common HTTP status codes classes

The list of HTTP status codes we can put into 5 classes:

  • Status codes 100: Informational requests - Informational codes indicating that the request initiated by the browser is continuing.
  • Status codes 200: Successful requests - Success codes returned when browser request was successfully received, understood, and processed by the server.
  • Stauts code 300: Redirect - Server sends to notify the availability of a new source that changes the originally requested page.
  • Status code 400: Client errors - Represent bugs in accessing the requested part. Client error codes indicating that there was a problem with the request.
  • Status code 500: Server errors - Appear when the page access is successful, but the server still has an error.

List of HTTP Status Codes:

In general, some of the most common status codes are 301 redirects, 404 not found, 504 gateway timeout, 400 bad request, 304 not modified, and 502 bad gateway – but there are many other status codes and you should be at least briefly familiar with some of the most important ones.

200 Status Code

  • 200: The server says everything is ok and in perfect order.

300 Status Codes

  • 301: “The requested resource has been moved permanently.” The source we are looking for is permanently transferred to another URL, or resource replaced with a different resource.
  • 302: “The requested resource has moved, but was found.” Server recognized the request, but is now engaged side to the other locations.
  • 304: “The requested resource has not been modified since the last time you accessed it.”

400 Status Codes

  • 401: “Unauthorized.” Target resource lacks valid authentication credentials.

  • 403: “Access to that resource is forbidden.” This is error when a user attempts to access something that they don’t have permission to access.

  • 404: “The requested resource was not found.” This code means that the requested resource does not exist and that the server does not know if it ever existed.

  • 405: “Method not allowed.” This is generated when the hosting server (origin server) supports the method received, but the target resource doesn’t.

  • 406: “Not acceptable response.” The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.

  • 408: “The server timed out waiting for the rest of the request from the browser.” This code means that the server didn’t get the full request that was sent by the browser.
  • 410: “The requested resource is gone and won’t be coming back.” The requested source has disappeared , like a case when you move away and leave no trace of yourself, and this is not good for SEO.
  • 429: “Too many requests.”
  • 429: too many requests
  • 429: too many requests
  • 499: “Client closed request.”

500 Status Codes

  • 500: “There was an error on the server and the request could not be completed.” Something went wrong on the server and the requested resource was not delivered. Usually problem is generated by third-party plugins, faulty PHP or connection to the database.
  • 501: “Not Implemented.” This is almost always a problem on the web server itself and usually must be resolved by the host.
  • 502: “Bad Gateway.” This error code typically means that one server has received an invalid response from another.
  • 503: “The server is unavailable to handle this request right now.” The server is in poor condition, or is currently overcrowded, or is in the maintenance process, or it does not work at all.
  • 504: “The server, acting as a gateway, timed out waiting for another server to respond.” The code returned when there are two servers involved in processing a request, and the first server times out waiting for the second server to respond.

Check http status code with cURL

In the end we want show you how to using curl at the CLI on Debian to issue HTTP requests.

Use the following cURL command and pipe it to grep:

$ curl -LI -s http://example.com /dev/null -w '%{http_code}\n' | grep "HTTP"

You shoud get following output.

Output:
HTTP/1.1 301 Moved Permanently
HTTP/2 200 

More info on curl parameters can be found below.

  • I: - Show only response headers
  • s: - Silent - Don’t show progress bar
  • L: - Follow Location: headers