Troubleshooting Techniques HTTP Error Codes That Are Common

Troubleshooting Techniques HTTP Error Codes That Are Common

Every HTTP request received by a server responds to an HTTP status code when accessing a web server or application. HTTP status codes are three-digit numbers that divide into five categories. The first digit of a status code can use to determine its class:

  • 1xx: Explanatory
  • 2xx: Achievement
  • 3xx: Reorientation
  • Client Error 4xx
  • Server Error 5xx

From a system administrator’s perspective, this article concentrates on detecting and diagnosing the most commonly encountered HTTP error codes, namely 4xx and 5xx status codes. Therefore, There are a variety of scenarios that might cause a web server to reply to a request. With a certain error code; we’ll go over the most prevalent causes and solutions.

Overview of Client and Server Errors

Client errors, often known as HTTP status codes 400 to 499, cause by HTTP requests submit a user client. Even though these types of issues are client-side. Knowing the error code a user is seeing can help identify if the problem can solve by server setup.

A web server returns server errors, or HTTP status codes ranging from 500 to 599. When it detects a problem or is otherwise unable to perform the request.

Tips for Troubleshooting in General

Refresh the browser after making server changes when using a web browser to test a web server.

More information on how the server handles requests can be found in the server logs. As a result, Web servers such as Apache and Nginx, for example, generate two log files named access.log and error.log. Which can search for important information.

Keep in mind that the definitions of HTTP status codes are part of a standard. That is to say, That implements by the program that serves requests. On the other hand, This implies that the actual status code provides determined how the server software handles a specific mistake; however, this guidance should point you in the correct way in general.

400 Internal Server Error

The 400 status code, often known as a Bad Request error, indicates that the HTTP request delivered to the server has incorrect syntax.

  • Here are some examples of when you could get a 400 Bad Request error:
  • A user’s cookie connected with the site has become corrupted. This problem might be resolved by clearing the cache and cookies in the browser.
  • A malfunctioning browser has resulted in a malformed request.
  • When manually creating HTTP requests, human mistake might result in malformed requests (e.g. using curl incorrectly)

Unauthorized 401

The 401 status code, often known as an Unauthorized error, indicates that the user attempting to access the resource was not authenticated or did not authenticate appropriately. This means that in order to visit the protected resource, the user must first give credentials.

If a user attempts to access a resource that is protected by HTTP authentication, such as this Nginx tutorial, a 401 Unauthorized error will be returned. In this situation, the user will obtain a 401 response code until they give the web server with a valid username and password (one from the.htpasswd file).

Forbidden 403

The 403 status code, often known as a forbidden error, indicates that the user sent a valid request, but the server is refusing to fulfill it because the user does not have authorization to access the requested resource. If you get a 403 error unexpectedly, there are a few common causes that we’ll go over here.

File Rights 403 errors are typical when the user running the web server process does not have enough permissions to read the file access.

Consider the following scenario as an example of how to debug a 403 error:

The user is attempting to access the index file on the web server at http://example.com/index.html.

The www-data user owns the web server worker process.

The index file placed at /usr/share/nginx/html/index.html on the server.

Check if the www-data user has appropriate permissions to view the file if the user receives a 403 Forbidden error. This usually signifies that the file’s other permissions should be set to read. There are a few ways to do this, however in this situation, the following command will suffice:

sudo chmod o=r /usr/share/nginx/html/index.html

.htaccess

The use of an . Htaccess file is another potential cause of 403 errors, which is often done on purpose. For example, the . Htaccess file can use to block access to specific IP addresses or ranges to specific resources.

If the user receives an unexpected 403 Forbidden error, be sure it’s not because of your. htaccess settings.

There is no index file

The web server will produce a 403 Forbidden error if the user tries to browse a directory that does not have a default index file and directory listings enable. Meanwhile, A 403 status will display if the user tries to access http://example.com/emptydir/ and there is no index file in the emptier directory on the server.

You can allow directory listings in your web server setup if you want to.

Not Found (404)

A 404 status code, often known as a Not Found error, indicates that the user can communicate with the server. Most importantly that the server is unable to locate the requested file or resource.

404 errors can occur in a wide range of circumstances. Here are some questions to ask while debugging if the user receives an unusual 404 Not Found error:

  • Is there a typographical problem in the link that sent the user to your server resource?
  • Is it possible that the user typed in the erroneous URL?
  • Is the file on the server in the correct location? Was the resource on the server moved or deleted?
  • Is the document root location in the server configuration correct?
  • Is it possible for the user who owns the web server worker process to traverse to the directory where the requested file locate? (Hint: to access directories, you’ll need to read and execute permissions.)
  • Is the resource you’re trying to go to a symbolic link? If this is the case, make sure the web server is set to follow symbolic links.

Internal Server Error 500

The 500 status code, which stands for Internal Server Error, indicates that the server is unable to perform the request for some reason. When more specific 5xx faults are more suitable, this code may show.

Server misconfiguration (e.g., a malformed. Htaccess file) or missing packages are the most prevalent causes of this error (e.g. trying to execute a PHP file without PHP installed properly).

Bad Gateway 502

The 502 status code, is also known as a Bad Gateway error. This indicates that the server is acting as a gateway or proxy server and is not receiving a legitimate answer from the backend servers that should be handling the request.

Here are a few things to look for if the server in question is a reverse proxy server, such as a load balancer:

  • The backend servers (to which HTTP requests are sent) are in good shape.
  • The reverse proxy properly configure, with the appropriate backends supplied.
  • The backend servers and reverse proxy server have a stable network connection. Make that the firewall allows traffic between the servers if they can communicate on other ports.
  • If your web application is set up to listen on a socket, double-check that the socket is in the right place and has the right permissions.

503 Unavailable Service

The 503 status code, which stands for “Service Unavailable,” indicates that the server overburden or undergoing maintenance. Similarly, This error indicates that the service will be accessible at some point in the future.

If the server maintains, it could mean that it doesn’t have enough CPU or RAM to handle all the incoming requests, or that the web server has to adjust to support more users, threads, or processes.

Gateway Timeout: 504

The 504 status code, is also known as the Gateway Timeout error. Indicates that the server is a gateway or proxy server that hasn’t received a response from the backend servers within the time limit.

This is most common in the following scenarios:

  • There is a bad network connection between the servers
  • Due to poor performance, the backend server that is completing the request is too slow
  • The timeout duration of the gateway or proxy server is insufficient

Conclusion

You should have a decent foundation for troubleshooting difficulties with your web servers or applications now that you’re familiar with the most common HTTP error codes and typical remedies to those codes.

Feel free to discuss any error codes that did not address in this article, or if you know of any other possible answers to the ones that were, in the comments.

LadiTech Web Development Services

PHP is a programming language. LadiTech is a highly effective team of programmers who are well-vers in PHP web development, PHP application development, and PHP software development. Above all, Our goal is to deliver high-quality online solutions that are highly competent, and error-free, and incorporate all the features listed on the client’s demand sheet. In the same way that websites must update from time to time, PHP application maintenance is akin to equipment maintenance.

LadiTech can help you maintain the integrity of your website. Creating new add-ons, changing existing systems, and conducting any other bespoke maintenance work are all part of our application maintenance services. These services allow our clients to focus on their core business while also increasing their customer base.

Share this on

Facebook
LinkedIn
Twitter
Pinterest
Email
WhatsApp
Telegram
Skype