[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[Things you need to remember] A simple explanation of HTTP status code errors as a refresher and refresher.

Introduction

Nice to meet you all!

This is Mikoto, a 24-year graduate from the System Solutions Department, and this is my first time writing a blog.
I couldn't think of a nickname, so my mother gave it to me.

would like to mainly explain 4XX and 5XX, which are called error codes among status codes, which I feel are important in my work

↑The error code is 401 in the image above!

To explain it, I will look at the status code from a sample of the access log recorded in the server, but for those who are not familiar with it, you can understand that this is how you usually analyze access by looking at it, so please take a quick look at it. I'm happy.

By the way, if you are interested in access logs, please refer to this page!
[Apache] Easy explanation of how to read access logs! * Updated in 2024
[nginx] Explanation of how to view, settings, location, etc. of access logs

 

What exactly is a status code?

A status code is a 3-digit number that a web server returns in response to an HTTP request , and you can check the status of the request you sent from this number!
You can check it from the developer tools (verification tools in Chrome), so please take a look if you like.


↑The part in the red frame is the status code!

Status codes are divided into five categories: Informational (1XX), Success (2XX), Redirection (3XX), Client Error (4XX), and Server Error (5XX) This will give you a clear understanding of whether the access was successful or, if not, where the problem was.

Two types of error codes

4XX - Client error

Status codes starting with 4 mainly indicate problems on the client side (user). This occurs when the server is unable to process the request due to an error in the content of the request, access not permitted, etc.

For example, we often see things like:

▼400 Bad Request:

127.0.0.1 - - [25/Dec/2023:14:25:00 +0900] "GET /api/data?date=2023-12-33 HTTP/1.1" 400 172 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

This is a 400 error because the client sent an incorrectly formatted request.
For example, in the example above, you can see that the client entered an invalid date (December 23, 2023) for '/api/data', resulting in a 400 error.

▼401 Unauthorized:

127.0.0.1 - - [25/Dec/2023:13:15:00 +0900] "POST /login HTTP/1.1" 401 187 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

This error represents a situation where the client has not provided proper authentication credentials.
In the above example, we made a POST request to /login and received a 401 error, indicating that we probably did not send the correct username, password, etc.

▼403 Forbidden:

127.0.0.1 - - [25/Dec/2023:13:20:00 +0900] "GET /admin/settings HTTP/1.1" 403 249 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/ 603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30"

Forbidden is an English word that means "forbidden," and as the name suggests, it is an error code that may be displayed when a request is sent to a path that only a limited number of users can access.
The example error shows that an unprivileged client sent a GET request to /admin/settings, but a 403 error was returned.

▼404 Not Found:

127.0.0.1 - - [25/Dec/2023:13:25:00 +0900] "GET /about-us HTTP/1.1" 404 210 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X ) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1"

This 404 error may be returned when the server cannot find the requested resource. There are several possible causes for this.

  1. User entered the URL incorrectly
  2. The specified page is old and no longer exists
  3. The correct URL was not set due to a server configuration error.
  4. Resource was temporarily moved or deleted

5XX - Server error

Status codes starting with 5 indicate a problem on the server side This occurs when the request from the client is successful, but for some reason the server cannot process it.

For example:

▼500 Internal Server Error:

127.0.0.1 - - [25/Dec/2023:14:00:00 +0900] "GET /dashboard HTTP/1.1" 500 215 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

This is the error code returned when an error occurs within the server and the request cannot be processed.

If you encounter this error, you may be able to find the cause by reviewing the most recently edited settings in the server!
Also, if an error occurs after making some configuration changes, you may be able to resolve the issue by switching back to a backup you made in advance!

▼503 Service Unavailable:

127.0.0.1 - - [25/Dec/2023:14:15:00 +0900] "GET /reports HTTP/1.1" 503 212 "-" "Mozilla/5.0 (iPad; CPU OS 13_6 like Mac OS X) AppleWebKit/ 605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1"

Indicates that the server is temporarily unable to process requests. This may be due to maintenance or overload.

For example, if there is a sudden increase in access, the server may be unable to handle it and return a 503 error!

▼504 Gateway Timeout:

127.0.0.1 - - [25/Dec/2023:14:20:00 +0900] "GET /video/stream HTTP/1.1" 504 160 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36"

This occurs when the load on the server increases for some reason, and the gateway/proxy server exceeds the specified time (timeout value) while waiting for a response from the upstream server.
It is becoming difficult to respond to requests from users within the time limit.

Additionally, restarting the middleware and temporarily resetting the connection may resolve the issue, but to prevent it from happening again, you need to investigate the reason why the process is taking so long.
(One solution is to extend the timeout value, but I have never seen an example where this was solved during work...)

Examples of causes include:

  1. I'm stuck doing something heavy.
  2. Performed a large database operation that consumed a lot of resources
  3. There is a problem with the network
  4. Something is wrong with the upstream server

Small story

▼418 I'm a teapot:

Are you familiar with this 418 error?

This status code was defined on April Fool's Day about 20 years ago, and
when you try to pour coffee into a teapot, you get an error saying that the coffee was refused.

Actually, it exists as a status code for HTCPCP (Hyper Text Coffee Pot Control Protocol) communication, not HTTP communication, and the verification tool shows the status as 418.

If you are interested, please check it out
here Also, like 418, HTCPCP is also an April Fool's joke, so check it out!

summary

This was an introduction to status codes called error codes!
In addition to this, there are also error codes output by specific middleware, such as 499, so if you are interested, please check them out!

Now that I'm in my first year working as an infrastructure engineer, status codes come up quite often, so I recommend studying them if you're interested. (I went in without knowing anything)

Thank you for watching!

Reference:
[Explanation of frequently seen items with a list] What is an HTTP status code? Detailed explanation by code number
HTTP status code list and detailed guide
HTTP response status code
What is http status code 418?

If you found this article helpful , please give it a like!
3
Loading...
3 votes, average: 1.00 / 13
192
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Mikoto

I am an infrastructure engineer who joined the company in April 2024 from the Faculty of Arts and Sciences.
I couldn't think of a nickname, so I chose one that my mother often uses.