Skip to content

abdullah89255/HTTP-server-status-codes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

HTTP-server-status-codes

Here’s a complete, clear guide to HTTP server status codes — what they mean, how they’re grouped, and real-world examples for each.


🌐 What Are HTTP Status Codes?

When you visit a website, your browser sends a request to a server. The server replies with a status code — a 3-digit number that tells what happened to your request.

For example:

HTTP/1.1 200 OK

means the request was successful.


🧩 HTTP Status Code Categories

Category Range Meaning
1xx 100–199 Informational responses
2xx 200–299 Success responses
3xx 300–399 Redirection messages
4xx 400–499 Client errors (your side)
5xx 500–599 Server errors (server side)

🔹 1xx — Informational

These mean the request was received and is being processed.

Code Message Example / Explanation
100 Continue Client can keep sending the rest of the request body
101 Switching Protocols Used for WebSocket upgrade requests
102 Processing Server has received the request but not finished processing (used in WebDAV)

🧠 Example:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade

🟢 2xx — Success

These mean your request succeeded.

Code Message Example / Explanation
200 OK Standard success code
201 Created A new resource was created (e.g., POST /users)
202 Accepted Request accepted but processing not finished
204 No Content Success, but no content in response
206 Partial Content Used for range requests (like video streaming)

🧠 Example:

HTTP/1.1 201 Created
Location: /users/45

🟡 3xx — Redirection

These tell the browser to go somewhere else.

Code Message Example / Explanation
301 Moved Permanently Resource has a new permanent URL
302 Found Temporary redirect (commonly used for login pages)
303 See Other Redirect after POST
304 Not Modified Browser cache still valid
307 Temporary Redirect Same as 302 but preserves request method
308 Permanent Redirect Same as 301 but preserves method

🧠 Example:

HTTP/1.1 301 Moved Permanently
Location: https://newsite.com/

🔴 4xx — Client Errors

These mean the problem is with the client (browser or request).

Code Message Example / Explanation
400 Bad Request Invalid request syntax
401 Unauthorized Authentication required
403 Forbidden You’re not allowed to access
404 Not Found Page or resource doesn’t exist
405 Method Not Allowed Wrong HTTP method (e.g., POST on GET endpoint)
408 Request Timeout Server waited too long for the client
409 Conflict Request conflicts with server state
410 Gone Resource deleted permanently
413 Payload Too Large File upload exceeds limit
429 Too Many Requests You’re rate-limited

🧠 Example:

HTTP/1.1 404 Not Found

🔥 5xx — Server Errors

These mean the server failed to fulfill a valid request.

Code Message Example / Explanation
500 Internal Server Error Generic error — something broke on the server
501 Not Implemented Server doesn’t support the request method
502 Bad Gateway Server got invalid response from upstream server
503 Service Unavailable Server overloaded or under maintenance
504 Gateway Timeout Upstream server didn’t respond in time
505 HTTP Version Not Supported Request used unsupported HTTP version

🧠 Examples:

HTTP/1.1 500 Internal Server Error
HTTP/1.1 503 Service Unavailable
Retry-After: 120

🧭 Summary Table

Code Meaning Type
100 Continue Info
200 OK Success
201 Created Success
204 No Content Success
301 Moved Permanently Redirect
302 Found Redirect
304 Not Modified Redirect
400 Bad Request Client Error
401 Unauthorized Client Error
403 Forbidden Client Error
404 Not Found Client Error
405 Method Not Allowed Client Error
408 Request Timeout Client Error
429 Too Many Requests Client Error
500 Internal Server Error Server Error
502 Bad Gateway Server Error
503 Service Unavailable Server Error
504 Gateway Timeout Server Error

🧰 How to Check HTTP Status Codes

🖥️ 1. Using curl

curl -I https://example.com

Output:

HTTP/1.1 200 OK

🕵️ 2. Using Browser Developer Tools

  • Open browser → F12 → Network tab → reload site → check "Status" column.

⚡ 3. Using Python

import requests
r = requests.get("https://example.com")
print(r.status_code)

About

HTTP server status codes — what they mean, how they’re grouped, and real-world examples for each.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published