प्रत्येक HTTP रिस्पॉन्स में एक तीन-अंकीय स्टेटस कोड होता है जो क्लाइंट को बताता है कि क्या हुआ। यह चीट शीट उन कोड को सूचीबद्ध करती है जिनसे आप सबसे अधिक मिलेंगे, वर्ग के अनुसार समूहित, प्रत्येक के संक्षिप्त विवरण के साथ।
चाहे आप REST API बना रहे हों, किसी रिक्वेस्ट को डिबग कर रहे हों, या रीडायरेक्ट कॉन्फ़िगर कर रहे हों, इस पेज को त्वरित संदर्भ के रूप में उपयोग करें कि प्रत्येक स्टेटस कोड का क्या अर्थ है और कब लौटाना है।
1xx — Informational
| Code | Meaning & when it's used |
|---|
100 Continue | The server received the request headers and the client should send the body. |
101 Switching Protocols | The server is switching protocols as requested (e.g. to WebSocket). |
103 Early Hints | Used to preload resources while the server prepares the response. |
2xx — Success
| Code | Meaning & when it's used |
|---|
200 OK | The request succeeded. The standard response for a successful GET. |
201 Created | The request succeeded and a new resource was created (after POST/PUT). |
202 Accepted | The request was accepted for processing but is not yet complete. |
204 No Content | The request succeeded but there is no content to return. |
206 Partial Content | The server is delivering part of the resource (used for range requests). |
3xx — Redirection
| Code | Meaning & when it's used |
|---|
301 Moved Permanently | The resource has permanently moved to a new URL. Update your links. |
302 Found | The resource is temporarily at a different URL. |
303 See Other | Redirect to another URL using GET (often after a POST). |
304 Not Modified | The cached version is still valid; no need to re-download. |
307 Temporary Redirect | Like 302 but the request method must not change. |
308 Permanent Redirect | Like 301 but the request method must not change. |
4xx — Client Errors
| Code | Meaning & when it's used |
|---|
400 Bad Request | The server could not understand the request (malformed syntax). |
401 Unauthorized | Authentication is required and has failed or not been provided. |
403 Forbidden | The server understood the request but refuses to authorize it. |
404 Not Found | The requested resource does not exist on the server. |
405 Method Not Allowed | The HTTP method is not supported for this resource. |
409 Conflict | The request conflicts with the current state of the resource. |
410 Gone | The resource is permanently gone and will not return. |
422 Unprocessable Entity | The request was well-formed but failed validation. |
429 Too Many Requests | The client sent too many requests (rate limiting). |
5xx — Server Errors
| Code | Meaning & when it's used |
|---|
500 Internal Server Error | A generic error — something went wrong on the server. |
501 Not Implemented | The server does not support the functionality required. |
502 Bad Gateway | An upstream server returned an invalid response. |
503 Service Unavailable | The server is overloaded or down for maintenance. |
504 Gateway Timeout | An upstream server did not respond in time. |
507 Insufficient Storage | The server cannot store the representation to complete the request. |
HTTP स्टेटस कोड चीट शीट से जुड़े सामान्य प्रश्न
HTTP स्टेटस कोड वर्गों का क्या मतलब है?
1xx सूचनात्मक हैं, 2xx का अर्थ सफलता, 3xx का अर्थ रीडायरेक्शन, 4xx क्लाइंट एरर हैं (रिक्वेस्ट गलत थी), और 5xx सर्वर एरर हैं (सर्वर विफल हुआ)।
401 और 403 में क्या अंतर है?
401 Unauthorized का अर्थ है कि आप प्रमाणित नहीं हैं — पहले लॉग इन करें। 403 Forbidden का अर्थ है कि आप प्रमाणित हैं लेकिन संसाधन तक पहुंचने की अनुमति नहीं है।
मुझे 301 बनाम 302 कब उपयोग करना चाहिए?
जब कोई URL स्थायी रूप से बदल गया हो तब 301 Moved Permanently का उपयोग करें (सर्च इंजन अपना इंडेक्स अपडेट करते हैं)। अस्थायी रीडायरेक्ट के लिए 302 Found का उपयोग करें जहां मूल URL लौटेगा।
429 Too Many Requests का क्या मतलब है?
क्लाइंट ने दिए गए समय में बहुत अधिक रिक्वेस्ट भेजी हैं और उसे रेट-लिमिट किया जा रहा है। रिस्पॉन्स में अक्सर Retry-After हेडर होता है जो बताता है कि फिर कब प्रयास करें।
क्या 200 ही एकमात्र सफलता कोड है?
नहीं। 2xx कोड में 201 Created (POST के बाद), 202 Accepted, और 204 No Content शामिल हैं — प्रत्येक थोड़े अलग तरीके से सफलता का संकेत देता है।