Tan Phat Media

HTTP Status Codes Reference

Tra cứu nhanh HTTP status codes và ý nghĩa

100

Continue

Server đã nhận headers, client có thể tiếp tục gửi body

101

Switching Protocols

Server đồng ý chuyển protocol (ví dụ: WebSocket)

200

OK

Request thành công

201

Created

Resource đã được tạo thành công (POST)

204

No Content

Thành công nhưng không có body trả về (DELETE)

206

Partial Content

Trả về một phần resource (Range requests)

301

Moved Permanently

Resource đã chuyển vĩnh viễn sang URL mới

302

Found

Resource tạm thời ở URL khác

304

Not Modified

Resource không thay đổi, dùng cache

307

Temporary Redirect

Redirect tạm thời, giữ nguyên method

308

Permanent Redirect

Redirect vĩnh viễn, giữ nguyên method

400

Bad Request

Request không hợp lệ (syntax error, invalid data)

401

Unauthorized

Chưa xác thực (cần login)

403

Forbidden

Không có quyền truy cập (đã login nhưng không đủ quyền)

404

Not Found

Resource không tồn tại

405

Method Not Allowed

HTTP method không được hỗ trợ cho URL này

408

Request Timeout

Server timeout khi chờ request

409

Conflict

Conflict với state hiện tại (ví dụ: duplicate)

410

Gone

Resource đã bị xóa vĩnh viễn

413

Payload Too Large

Request body quá lớn

415

Unsupported Media Type

Content-Type không được hỗ trợ

422

Unprocessable Entity

Validation error (data đúng format nhưng không hợp lệ)

429

Too Many Requests

Rate limit exceeded

500

Internal Server Error

Lỗi server không xác định

501

Not Implemented

Server không hỗ trợ chức năng này

502

Bad Gateway

Gateway/proxy nhận response không hợp lệ từ upstream

503

Service Unavailable

Server tạm thời không khả dụng (maintenance, overload)

504

Gateway Timeout

Gateway/proxy timeout khi chờ upstream

HTTP Status Codes Reference - Tra cứu đầy đủ mã HTTP cho Developers

Công cụ tra cứu HTTP Status Codes của Tấn Phát Digital là reference guide đầy đủ nhất cho developers cần hiểu và sử dụng HTTP status codes đúng cách. Bao gồm 28+ status codes phổ biến nhất được phân loại theo 5 categories: 1xx Informational (100 Continue, 101 Switching Protocols), 2xx Success (200 OK, 201 Created, 204 No Content, 206 Partial Content), 3xx Redirection (301 Moved Permanently, 302 Found, 304 Not Modified, 307/308 Redirects), 4xx Client Errors (400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 405 Method Not Allowed, 408 Timeout, 409 Conflict, 410 Gone, 413 Payload Too Large, 415 Unsupported Media Type, 422 Unprocessable Entity, 429 Too Many Requests), 5xx Server Errors (500 Internal Server Error, 501 Not Implemented, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout). Mỗi status code có giải thích tiếng Việt rõ ràng về ý nghĩa và use cases. Tìm kiếm nhanh theo code number hoặc tên, filter theo category với color-coded badges. Copy status code với một click. Hoàn toàn miễn phí, không cần đăng ký.

Tính năng nổi bật

28+ HTTP status codes phổ biến nhất với giải thích chi tiết
Phân loại theo 5 categories: 1xx, 2xx, 3xx, 4xx, 5xx
Color-coded badges: xanh (2xx), vàng (3xx), cam (4xx), đỏ (5xx)
Giải thích tiếng Việt dễ hiểu cho mỗi status code
Tìm kiếm nhanh theo code number (200, 404...)
Tìm kiếm theo tên (OK, Not Found, Forbidden...)
Tìm kiếm theo mô tả (authentication, redirect...)
Filter theo category để focus vào nhóm cần thiết
Copy status code với một click
Giao diện cards dễ scan và đọc
Responsive design, dùng được trên mobile
Hoàn toàn miễn phí, không cần đăng ký

Tại sao developers cần hiểu HTTP Status Codes?

HTTP Status Codes là ngôn ngữ giao tiếp giữa client và server, cho biết kết quả của mỗi HTTP request. Hiểu đúng status codes giúp developers: Debug API issues hiệu quả - biết ngay vấn đề là ở client (4xx) hay server (5xx), authentication (401) hay authorization (403). Thiết kế RESTful APIs đúng chuẩn - return đúng status code cho mỗi operation (201 cho create, 204 cho delete, 422 cho validation errors). Handle errors gracefully trong frontend - hiển thị messages phù hợp cho users dựa trên status code. Implement proper redirects cho SEO - 301 cho permanent, 302/307 cho temporary. Monitor và alert - setup alerts cho 5xx errors, track 4xx patterns. Caching strategies - 304 Not Modified cho conditional requests. Rate limiting - handle 429 Too Many Requests properly. Đây là kiến thức fundamental mà mọi web developer cần master.

Lợi ích khi sử dụng

  • Quick reference khi debug API issues
  • Học và nhớ status codes dễ dàng hơn
  • Thiết kế APIs đúng chuẩn RESTful
  • Handle errors properly trong frontend
  • Communicate với team bằng standard terminology
  • Interview preparation cho web developer positions
  • Tiết kiệm thời gian tra cứu documentation
  • Offline reference sau khi load trang

Hướng dẫn sử dụng HTTP Status Codes Reference

  1. 1Mở trang và xem danh sách tất cả status codes
  2. 2Dùng ô tìm kiếm để search theo code (404) hoặc tên (Not Found)
  3. 3Hoặc click vào category buttons (2xx, 4xx, 5xx) để filter
  4. 4Đọc mô tả tiếng Việt để hiểu ý nghĩa và use cases
  5. 5Click icon copy để copy status code number
  6. 6Bookmark trang để reference nhanh khi cần

1xx Informational - Status codes thông tin

1xx status codes indicate provisional responses, thường không gặp trong typical web development nhưng quan trọng trong specific scenarios. 100 Continue - Server đã nhận request headers và client có thể tiếp tục gửi request body. Useful cho large uploads: client gửi Expect: 100-continue header, server respond 100 nếu OK để proceed, hoặc 4xx nếu reject sớm (save bandwidth). 101 Switching Protocols - Server đồng ý upgrade protocol theo client request. Phổ biến nhất trong WebSocket handshake: client gửi Upgrade: websocket header, server respond 101 và switch sang WebSocket protocol. 102 Processing (WebDAV) - Server đã nhận request và đang xử lý, nhưng chưa có response. Prevent client timeout cho long-running operations. 103 Early Hints - Server gửi preliminary response với Link headers để client có thể preload resources trong khi server đang prepare final response. Improve performance cho complex pages.

2xx Success - Status codes thành công

2xx status codes indicate request was successfully received, understood, and accepted. 200 OK - Standard success response. GET: return requested resource. POST: return result of action. PUT/PATCH: return updated resource. 201 Created - Resource mới được tạo thành công. Dùng cho POST requests tạo new entities. Should include Location header với URL của new resource. 202 Accepted - Request accepted nhưng chưa xử lý xong. Dùng cho async operations: queue jobs, batch processing. Client có thể poll status endpoint. 204 No Content - Success nhưng không có response body. Dùng cho DELETE requests, hoặc PUT/PATCH khi không cần return updated resource. 206 Partial Content - Server trả về một phần của resource. Dùng cho Range requests: video streaming, resumable downloads. Response includes Content-Range header. Best practices: Luôn return 2xx cho successful operations. Include relevant data trong response body. Use 201 với Location header cho creates. Use 204 cho deletes và updates không cần response.

3xx Redirection - Status codes chuyển hướng

3xx status codes indicate client must take additional action to complete request. 301 Moved Permanently - Resource đã chuyển vĩnh viễn sang URL mới. Browsers và search engines cache redirect này. Dùng cho: domain changes, URL restructuring, HTTP to HTTPS. SEO: passes link equity to new URL. 302 Found (Previously 'Moved Temporarily') - Resource tạm thời ở URL khác. Browsers không cache. Dùng cho: temporary maintenance, A/B testing, geo-redirects. 303 See Other - Response ở URL khác, client should GET that URL. Dùng sau POST để redirect đến result page (POST-Redirect-GET pattern). 304 Not Modified - Resource không thay đổi since last request. Client should use cached version. Dùng với conditional requests (If-Modified-Since, If-None-Match headers). Saves bandwidth. 307 Temporary Redirect - Giống 302 nhưng guarantee giữ nguyên HTTP method. POST request sẽ được redirect as POST, không convert sang GET. 308 Permanent Redirect - Giống 301 nhưng guarantee giữ nguyên HTTP method. SEO implications: 301/308 cho permanent changes, 302/307 cho temporary. Always include Location header.

4xx Client Errors - Lỗi từ phía client

4xx status codes indicate client made an error. 400 Bad Request - Request syntax invalid hoặc cannot be fulfilled. Dùng cho: malformed JSON, missing required fields, invalid query params. Include error details trong response body. 401 Unauthorized - Authentication required hoặc failed. Client chưa provide credentials hoặc credentials invalid. Should include WWW-Authenticate header. 403 Forbidden - Server understood request nhưng refuses to authorize. Client authenticated nhưng không có permission. Khác 401: 401 = 'who are you?', 403 = 'I know who you are but no'. 404 Not Found - Resource không tồn tại. Có thể là: URL sai, resource deleted, hoặc intentionally hidden (security). 405 Method Not Allowed - HTTP method không supported cho URL này. Include Allow header listing supported methods. 409 Conflict - Request conflicts với current state. Dùng cho: duplicate entries, version conflicts, business rule violations. 422 Unprocessable Entity - Request well-formed nhưng semantic errors. Dùng cho validation errors: invalid email format, password too short. 429 Too Many Requests - Rate limit exceeded. Include Retry-After header. Client should implement exponential backoff.

5xx Server Errors - Lỗi từ phía server

5xx status codes indicate server failed to fulfill valid request. 500 Internal Server Error - Generic server error. Something went wrong nhưng server không biết specifically what. Dùng khi: unhandled exceptions, unexpected errors. Log details server-side, return generic message to client (security). 501 Not Implemented - Server không support functionality required. Dùng khi: feature not yet implemented, unsupported HTTP method. 502 Bad Gateway - Server acting as gateway/proxy received invalid response từ upstream server. Common trong: load balancers, reverse proxies, microservices. Check upstream server health. 503 Service Unavailable - Server temporarily unable to handle request. Reasons: maintenance, overload, dependency down. Include Retry-After header nếu biết when available. 504 Gateway Timeout - Gateway/proxy didn't receive timely response từ upstream. Similar to 502 nhưng specifically timeout. Check upstream server performance, increase timeout settings. Best practices: Never expose internal error details to clients (security risk). Log full error details server-side. Return user-friendly messages. Implement proper error monitoring và alerting cho 5xx errors.

Câu hỏi thường gặp (FAQ)

401 Unauthorized và 403 Forbidden khác nhau thế nào? Khi nào dùng cái nào?

401 Unauthorized nghĩa là 'authentication required' - client chưa provide credentials hoặc credentials invalid. Server không biết client là ai. Response should include WWW-Authenticate header. 403 Forbidden nghĩa là 'authorization denied' - server biết client là ai (đã authenticated) nhưng client không có permission để access resource. Ví dụ: 401 khi chưa login, 403 khi đã login nhưng không phải admin mà access admin page. Một số APIs dùng 404 thay vì 403 để không reveal resource existence (security through obscurity).

Khi nào dùng 404 Not Found vs 410 Gone?

404 Not Found: Resource không tồn tại, hoặc server không muốn reveal có tồn tại hay không. Có thể là temporary (URL sai) hoặc permanent. Search engines sẽ retry. 410 Gone: Resource đã từng tồn tại nhưng đã bị xóa vĩnh viễn và sẽ không quay lại. Search engines sẽ remove từ index nhanh hơn 404. Dùng 410 khi: intentionally delete content, discontinue product pages, remove user accounts. Dùng 404 khi: URL never existed, typo, hoặc không chắc chắn.

301 và 302 redirect khác nhau thế nào? Ảnh hưởng SEO ra sao?

301 Moved Permanently: Resource đã chuyển vĩnh viễn. Browsers cache redirect. Search engines transfer ~90-99% link equity sang new URL và update index. Dùng cho: domain migrations, permanent URL changes, HTTP to HTTPS. 302 Found (Temporary): Resource tạm thời ở URL khác. Browsers không cache. Search engines keep original URL trong index. Dùng cho: A/B testing, temporary maintenance, geo-redirects. SEO impact: Dùng sai 302 cho permanent changes sẽ không transfer link equity properly. Luôn dùng 301 cho permanent changes.

200 OK vs 201 Created vs 204 No Content - khi nào dùng cái nào?

200 OK: General success. Dùng cho GET requests, và POST/PUT/PATCH khi return data trong response. 201 Created: Resource mới được tạo. Dùng cho POST requests tạo new entities. Should include Location header với URL của new resource, và optionally return created resource trong body. 204 No Content: Success nhưng không có response body. Dùng cho: DELETE requests (resource deleted, nothing to return), PUT/PATCH khi client không cần updated resource back, actions không return data. Best practice: Be consistent trong API - document rõ ràng expected responses.

Làm sao handle 429 Too Many Requests properly?

429 indicates rate limit exceeded. Proper handling: 1) Check Retry-After header - server may specify when to retry (seconds hoặc HTTP date). 2) Implement exponential backoff - wait 1s, then 2s, 4s, 8s... 3) Add jitter - random delay để avoid thundering herd. 4) Queue requests - don't drop, queue và process slowly. 5) Cache responses - reduce need for repeated requests. 6) Show user-friendly message - 'Too many requests, please wait'. 7) Log và monitor - track rate limit hits để adjust client behavior hoặc request higher limits.

500 Internal Server Error - làm sao debug và handle?

500 là generic error khi server không biết specifically what went wrong. Debugging: 1) Check server logs - full stack trace should be logged. 2) Check recent deployments - new code có thể cause issues. 3) Check dependencies - database, external APIs, file system. 4) Check resources - memory, disk space, connections. Handling: 1) Never expose internal details to client (security). 2) Return generic user-friendly message. 3) Log full details server-side với request ID. 4) Setup alerting cho 5xx spikes. 5) Implement circuit breakers cho external dependencies. 6) Have runbooks cho common issues.

Có nên dùng custom status codes không?

KHÔNG recommend. HTTP spec defines standard codes, và clients/proxies/tools expect standard codes. Custom codes (ví dụ 499, 599) có thể: 1) Bị misinterpreted bởi proxies và load balancers. 2) Không được handle properly bởi HTTP libraries. 3) Confuse developers và tools. Thay vào đó: Dùng standard codes và include details trong response body. Ví dụ: 400 với body {"error": "INVALID_EMAIL", "message": "Email format invalid"}. Một số services (Cloudflare, nginx) có custom codes cho internal use, nhưng đây là exceptions.

Status codes nào quan trọng nhất cần nhớ?

Essential codes mọi developer cần nhớ: 200 OK - success. 201 Created - resource created. 204 No Content - success, no body. 301 Moved Permanently - permanent redirect. 302 Found - temporary redirect. 304 Not Modified - use cache. 400 Bad Request - client error. 401 Unauthorized - need authentication. 403 Forbidden - no permission. 404 Not Found - resource doesn't exist. 422 Unprocessable Entity - validation error. 429 Too Many Requests - rate limited. 500 Internal Server Error - server error. 502 Bad Gateway - upstream error. 503 Service Unavailable - server down. Những codes này cover 95%+ use cases trong web development.

Từ khóa liên quan

http status codesmã httphttp response codesrest api status codeshttp error codes200 ok404 not found500 internal server error401 unauthorized403 forbiddenhttp status referenceapi status codes

Hợp tác ngay với Tấn Phát Digital

Chúng tôi không chỉ thiết kế website, mà còn giúp doanh nghiệp xây dựng thương hiệu số mạnh mẽ. Cung cấp dịch vụ thiết kế website trọn gói từ thiết kế đến tối ưu SEO. Hãy liên hệ ngay với Tấn Phát Digital để cùng tạo nên những giải pháp công nghệ đột phá, hiệu quả và bền vững cho doanh nghiệp của bạn tại Hồ Chí Minh.

Zalo
Facebook
Tấn Phát Digital
Zalo
Facebook