Troubleshooting Common HTTP Errors

In this post, let’s have a look at common HTTP errors and how to troubleshoot them. HTTP error messages are classified into:

  • 1XX – Informational
  • 2XX – Success
  • 3XX – Redirect
  • 4XX – Client error
  • 5XX – Server error

Since we want to look at errors or problems, we’ll skip straight to 4XX and 5XX errors. The common ones are listed below.

400 – Bad Request

This indicates the request wasn’t properly structured or there was something wrong with the request. In most cases, it could be a browser or cookie related issue. If we still have issues after switching browsers and clearing cookies, we may want to look at how the request was formed.

401 – Unauthorized

This indicates whatever we are trying to access requires proper authorization. Either we provided incorrect credentials or our current user is simply not authorized to access this resource.

403 – Forbidden

This indicates we don’t have the right permission to access the requested resource. If the file we’re trying to access doesn’t have correct permissions, we can change it using chmod.

If file permissions are okay, it’s possible .htaccess could be denying access to specific IP ranges or we’re trying to access an empty directory that doesn’t have a default index file.

One of the potential solutions is to whitelist the IP address requesting this resource (to make sure that particular IP is not blocked).

404 – Not Found

This is the most common HTTP error. We may have mistyped the site address or the file that we’re requesting is simply not present.

500 – Internal Server Error

This is a generic server side error. We don’t know what went wrong and so we may have to do a couple of checks before we locate the issue. For example, what was the last change we did on the site before we started seeing this error? It could be changes to the PHP code or a new plugin/theme install on WordPress. We may need to look into error logs.

502 – Bad Gateway

This indicates the server is a gateway/proxy server and is not receiving a valid response from the backend server (which should be fulfilling this request). If this proxy server is a load balancer, check if backend server(s) are healthy.

503 – Service Unavailable

It could mean the server is overloaded or under maintenance. 503 says the service is temporarily unavailable and it’ll become available at some point.

We can check if it is overloaded by loading the site multiple times. If it loads a few times, it could mean the server needs more CPU or memory resources to handle the incoming requests.

We can also check analytics or other monitoring tools to see if there was a spike in the incoming requests.

504 – Gateway Timeout

It means that the gateway/proxy did not receive a response from the backend server within a specfic time period.

It could mean there’s a problem wtih network connectivity between the servers, or that the backend server is too slow or the timeout duration is too short.

In any case, for all 5XX error messages, we may still need to go through general troubleshooting steps mentioned under error 500, like checking PHP code, latest changes, looking at error logs, etc.

References

Digital Ocean: https://www.digitalocean.com/community/tutorials/how-to-troubleshoot-common-http-error-codes

Mozilla: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

Wiki: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

HTTP Statuses: https://httpstatuses.com/

Leave a comment