HTTP Status Codes Reference

รายการ HTTP status codes พร้อมคำอธิบายภาษาไทยและตัวอย่างการใช้งาน

1xx Informational

100

Continue

เซิร์ฟเวอร์ได้รับส่วนแรกของคำขอแล้ว ให้ส่งส่วนที่เหลือต่อได้

ใช้กับ Expect: 100-continue header

101

Switching Protocols

เซิร์ฟเวอร์ยอมรับการเปลี่ยน protocol ตามที่ client ขอ

ใช้เมื่อ upgrade เป็น WebSocket

2xx Success

200

OK

คำขอสำเร็จ

response ทั่วไปสำหรับ GET, POST ที่สำเร็จ

201

Created

สร้าง resource ใหม่สำเร็จ

หลัง POST สร้าง record ใหม่ใน database

204

No Content

สำเร็จแต่ไม่มีข้อมูลตอบกลับ

หลัง DELETE หรือ PUT ที่ไม่ต้องการ response body

206

Partial Content

ส่งข้อมูลบางส่วนตาม Range header

ใช้กับ video streaming หรือการดาวน์โหลดแบบแบ่งส่วน

3xx Redirect

301

Moved Permanently

URL ย้ายถาวรไปที่ URL ใหม่

redirect โดเมนเก่าไปโดเมนใหม่

302

Found

URL ย้ายชั่วคราว

redirect ชั่วคราวระหว่าง maintenance

304

Not Modified

ข้อมูลไม่มีการเปลี่ยนแปลง ใช้ cache เดิมได้

browser cache validation ด้วย ETag/Last-Modified

307

Temporary Redirect

redirect ชั่วคราว รักษา HTTP method เดิม

redirect POST request ชั่วคราว

308

Permanent Redirect

redirect ถาวร รักษา HTTP method เดิม

redirect POST request ถาวร

4xx Client Error

400

Bad Request

คำขอมีรูปแบบผิดพลาดหรือข้อมูลไม่ถูกต้อง

ส่ง JSON ที่ invalid หรือ parameter ไม่ครบ

401

Unauthorized

ต้องการการยืนยันตัวตน

เข้าถึง API โดยไม่มี token

403

Forbidden

server เข้าใจคำขอแต่ปฏิเสธการเข้าถึง

ไฟล์มี permission 000 หรือ IP ถูก block

404

Not Found

ไม่พบ resource ที่ขอ

URL พิมพ์ผิด หรือหน้าถูกลบแล้ว

405

Method Not Allowed

HTTP method ไม่ได้รับอนุญาตสำหรับ endpoint นี้

ส่ง POST ไปยัง endpoint ที่รับแค่ GET

408

Request Timeout

client ส่งคำขอช้าเกินไป

connection ที่ช้าหรือค้างระหว่างส่งข้อมูล

409

Conflict

คำขอขัดแย้งกับสถานะปัจจุบันของ resource

สร้าง user ด้วย email ที่มีอยู่แล้ว

410

Gone

resource ถูกลบถาวรและไม่มี redirect

หน้าที่ถูกลบและไม่มีการ redirect

413

Content Too Large

ข้อมูลที่ส่งมีขนาดใหญ่เกิน limit

อัปโหลดไฟล์ขนาดใหญ่เกิน upload_max_filesize

429

Too Many Requests

ส่งคำขอมากเกินกว่า rate limit

เรียก API เร็วเกินไปจน trigger rate limiting

5xx Server Error

500

Internal Server Error

เซิร์ฟเวอร์เกิดข้อผิดพลาดที่ไม่คาดคิด

PHP error, database connection fail

501

Not Implemented

server ไม่รองรับ HTTP method ที่ขอ

ใช้ PATCH กับ server ที่ไม่ implement

502

Bad Gateway

server กลางได้รับ response ที่ไม่ถูกต้องจาก upstream

Nginx ติดต่อ PHP-FPM ไม่ได้

503

Service Unavailable

server ไม่สามารถให้บริการได้ชั่วคราว

server โอเวอร์โหลดหรืออยู่ในช่วง maintenance

504

Gateway Timeout

server กลางรอ response จาก upstream นานเกินไป

PHP script ทำงานนานเกิน fastcgi_read_timeout