News
Seven days of Black Friday madness — great deal from Serverspace!

THE NEW YEAR
WHEEL OF FORTUNE

Spin the wheel and win a guaranteed prize right now!

By registering, you are signing up to receiving emails.
RF
August 2 2023
Updated August 2 2023

How To Troubleshoot Common HTTP Error Codes?

NGINX Web server

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:

  • Test Database Connections: Verify database connection settings and accessibility, if the application relies on a database;
  • Debug Application Code: Inspect application code for potential issues causing the error;
  • Check Network Connectivity: Verify network and firewall settings that might block client access;
  • Use Online Resources: Leverage developer forums and online resources for shared experiences and solutions;
  • Implement Fixes: Apply identified fixes to address the HTTP error codes.

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:

  • Misconfigured software or presence bug in the browser application;
  • Human error due to inattention, which URL request don't accordance to setup rules;
  • The cookies corrupt due to any impact for browser's storage.
400 error
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!

401
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!

Forbidden
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.

  • What process was happened when you get this error?
  • Do you indicate right path to the directory root?
  • Do files required exist on your system?

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

nano /etc/apache2/apache2.conf
404
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!

Internal
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:

  • Healthy and response of the backend part, also check their configuration;
  • Check configuration on the proxy side and able to communicate in another port, maybe, ports are you used was busy by another software;
  • Check status of the network connection and configuration of the system, you can send data through the netcat utility and test data transfer;
  • If your web—application use socket you need to check their location, it has access and permission.

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.

503 error
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.

Vote:
4 out of 5
Аverage rating : 4.8
Rated by: 4
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.