02.08.2023

How To Troubleshoot Common HTTP Error Codes?

Introduction

Effectively solving HTTP error codes poses a significant challenge, as it requires a comprehensive understanding of the underlying causes and adept troubleshooting skills. These error codes, represented by three-digit numbers (e.g., 404, 500), signify issues with the client's request or server processing. Identifying the specific error and its root cause demands knowledge of the HTTP protocol, server configurations, and application behavior.

Basic guide

The process involves determine the exact HTTP error code returned by the server (e.g., 404, 500).

Check Server Logs: Analyze server logs to gain insights into the error's timing and source. In the Apache and Nginx web—server we can check log via command below:

cat /var/log/apache2/error.log

To view the Nginx access log, you can use the cat, less, or tail command. Via command below check your event—file:

tail -n 50 /var/log/apache2/error.log

Review Server Configuration: Validate virtual host configurations and .htaccess files for potential misconfiguration. You can also as we say previous use cat or nano utility:

nano /etc/apache2/apache2.conf
nano /etc/apache2/sites-available/000-default.conf

Second command it's configuration for virtual host that we should check for properly work. For Nginx server we will use:

nano /etc/nginx/nginx.conf
nano /etc/nginx/nginx.conf

Clear cookies and cache memory: Ensure that you after apply changes on the site, you clean browser from temporary storage information.

The location might differ depending on the browser, but usually, you can find it in Settings or Preferences under Privacy & Security, labeled as Clear Browsing Data or Clear History.

If that basic measures wasn't useful you can try to:

Resolving HTTP errors demands a systematic and methodical approach, especially for complex web applications. Maintaining up—to—date server and application software and adhering to web development best practices can help prevent HTTP errors from occurring in the future. Let's have a look at type of common error code more thoroughly!

400 Bad Request

That means server get incorrect syntax in HTTP request from client side, which can appears due to:

Screenshot №1 — 400 error

401 Unauthorized Error

That means server can't give access to user on the site due to issue unauthorized. That can appear by incorrect enter credentials and corrupt identify, authorized system. Consequently, the user is required to furnish credentials in order to gain access and view the protected resource. To solve that problem we can ask web—server administrator to check .htpasswd and enter credentials for properly work our site:

find ./ -name .htpasswd

Using that path you can open file with nano text editor, write syntax nano and then path to open your file!

Screenshot №2 — 401 error

403 Forbidden

In that case we struggle with denied rules on the web-server to connections from our network or machine. To solve appears issue check main problem. File permissions may be haven't by user on the server, lets have a look on typical in that case configuration. We have user www—data for manage server, we trying to get access to the file .php or .html then add rule to read file:

chmod 644 /etc/site-for-test/index.html

In another situations, .htaccess file could add their specific deny rules on the server, determine they location we can through the work directory, usually they write like override rule or through the command below:

find ./ -name .htaccess

But there is another reason for that error, if web—server don't have index file or directory listing then server give the message of deny. If you want to enable listing of site, go to the config and change accordance parameter:

nano /etc/apache2/apache2.conf

That will help with troubleshoot at that error!

Screenshot №3 — 403 error

404 Not Found

When are you faced to that issue in the moment of connection you need to determine main question.

And more another question which say about misconfigured settings on the web-server or incorrect URL request:

nano /etc/apache2/apache2.conf

Screenshot №4 — 404 error

500 Internal Server Issue

That means server recieve request but cannot process it, due to unknown issue on the web—server side. Usually appears when two ore more issues there are on th server. Can happened in the different scenarios for example: misconfigured system file .htaccess, .htpasswd and more another settings, or missing HTML file to form reply to the client, check log of the server as we display at the basic guide above!

Screenshot №4 — 500 error

502 Bad Gateway or 504 Gateway timeout

The server say gateway or proxy—server don get properly response from the backend server. If you use proxy for transfering traffic then check:

503 Service Unavailable

That issue means server can not process all request from clients. If your machine is not being serviced, then scale up CPU, RAM resources and check simultaneously user, threads and process access into the server configuration! The error may also indicate an incorrect configuration of the load balancer to check its correct configuration. Go to /etc/nginx/nginx.conf and make sure the format and correctness of the entries.

Screenshot №5 — 503 error

Conclusion

Effectively troubleshooting and resolving common HTTP—error codes require a deep understanding of the underlying causes and skillful problem—solving techniques. These error codes, represented by three—digit numbers, indicate issues with client requests or server processing. To address HTTP—errors, one must be familiar with the HTTP—protocol, server configurations, and application behavior.