Common 400 HTTP Status Codes and Causes
Here’s a detailed explanation of common 4xx HTTP status codes, which indicate client-side errors—meaning the request sent to the server was incorrect or cannot be fulfilled.
Common 4xx Status Codes
400 Bad Request
- Meaning: The server cannot process the request due to malformed syntax.
- Causes:
- Invalid URL or query parameters
- Corrupted request payload
- Missing required headers
- Example: Sending a JSON payload with incorrect formatting.
401 Unauthorized
- Meaning: Authentication is required and has either failed or not been provided.
- Causes:
- Missing or invalid API key/token
- Incorrect login credentials
- Note: Often used with WWW-Authenticate header to indicate how to authenticate.
- Example: Accessing a protected resource without logging in.
403 Forbidden
- Meaning: The server understands the request but refuses to authorize it.
- Causes:
- Insufficient permissions
- IP or user blocked
- Access control rules denying access
- Example: Attempting to access an admin page without the necessary admin rights.
404 Not Found
- Meaning: The requested resource could not be found on the server.
- Causes:
- Incorrect URL
- Deleted or moved resource
- Example: Visiting a broken link or a URL with a typo.
405 Method Not Allowed
- Meaning: The HTTP method used is not allowed for the requested resource.
- Causes:
- Using POST on a resource that only accepts GET
- Example: Trying to delete a resource using GET instead of DELETE.
408 Request Timeout
- Meaning: The server timed out waiting for the client to send the full request.
- Causes:
- Slow internet connection
- The client took too long to send data
- Example: A form submission that stalls before completion.
409 Conflict
- Meaning: The request could not be completed due to a conflict with the current state of the resource.
- Causes:
- Duplicate entries
- Versioning conflicts in APIs
- Example: Trying to create a user with an email that already exists.
410 Gone
- Meaning: The resource is no longer available and will not be available again.
- Causes:
- Resource intentionally removed
- Deprecated API endpoint
- Example: Accessing a page that has been permanently deleted.
429 Too Many Requests
- Meaning: The user has sent too many requests in a given time (rate limiting).
- Causes:
- API abuse
- Bot traffic
- Example: Making hundreds of API calls in a few seconds.
No comments:
Post a Comment