Error Code Reference
Quick reference guide for HTTP status codes and common error messages
HTTP Status Codes
1xx - Informational
| Code | Name | Description |
|---|---|---|
| 100 | Continue | The client should continue with its request |
| 101 | Switching Protocols | Server is switching protocols as requested by the client |
2xx - Success
| Code | Name | Description |
|---|---|---|
| 200 | OK | The request was successful |
| 201 | Created | A new resource was successfully created |
| 202 | Accepted | The request has been accepted for processing |
| 204 | No Content | The server successfully processed the request with no content to return |
3xx - Redirection
| Code | Name | Description |
|---|---|---|
| 301 | Moved Permanently | The resource has been permanently moved to a new URL |
| 302 | Found | The resource temporarily resides at a different URL |
| 304 | Not Modified | The resource has not been modified since last requested |
4xx - Client Errors
| Code | Name | Description |
|---|---|---|
| 400 | Bad Request | The server cannot process the request due to client error |
| 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 could not be found |
| 405 | Method Not Allowed | The request method is not supported for this resource |
| 408 | Request Timeout | The server timed out waiting for the request |
| 409 | Conflict | The request conflicts with the current state of the server |
| 422 | Unprocessable Entity | The request was well-formed but contains semantic errors |
| 429 | Too Many Requests | The user has sent too many requests in a given time |
5xx - Server Errors
| Code | Name | Description |
|---|---|---|
| 500 | Internal Server Error | A generic error occurred on the server |
| 501 | Not Implemented | The server does not support the functionality required |
| 502 | Bad Gateway | The server received an invalid response from an upstream server |
| 503 | Service Unavailable | The server is temporarily unable to handle the request |
| 504 | Gateway Timeout | The server did not receive a timely response from an upstream server |
Common Error Types
Database Errors
| Error Name | Description |
|---|---|
| Connection Timeout | Unable to establish database connection within timeout period |
| Duplicate Key | Attempt to insert a record with a duplicate primary key |
| Foreign Key Constraint | Operation violates a foreign key constraint |
| Deadlock | Two or more transactions waiting for each other to release locks |
Network Errors
| Error Name | Description |
|---|---|
| Connection Refused | Target server is not accepting connections |
| DNS Resolution Failed | Unable to resolve hostname to IP address |
| Network Timeout | Network operation exceeded timeout period |
| SSL/TLS Handshake Failed | Failed to establish secure connection |
Authentication Errors
| Error Name | Description |
|---|---|
| Invalid Credentials | Username or password is incorrect |
| Token Expired | Authentication token has expired and needs renewal |
| Insufficient Permissions | User lacks necessary permissions for the operation |
| Account Locked | Account has been locked due to security policy |
Validation Errors
| Error Name | Description |
|---|---|
| Required Field Missing | A required field was not provided |
| Invalid Format | Data does not match expected format |
| Value Out of Range | Numeric value exceeds allowed range |
| Invalid Type | Data type does not match expected type |
Quick Reference
Status Code Categories:
-
1xx Informational
Request received, continuing process -
2xx Success
Action successfully received and accepted -
3xx Redirection
Further action needed to complete request -
4xx Client Error
Request contains bad syntax or cannot be fulfilled -
5xx Server Error
Server failed to fulfill valid request
Most Common Codes
200 OK
Success
201 Created
Success
400 Bad Request
Client Error
401 Unauthorized
Client Error
404 Not Found
Client Error
500 Server Error
Server Error
Testing Tips
- Always test error handling for 4xx and 5xx codes
- Verify appropriate status codes are returned
- Check error messages are user-friendly
- Test authentication with 401 and 403
- Simulate server errors (500, 503)
- Verify redirects (301, 302) work correctly
API Error Best Practices
Good Error Response:
{
"error": {
"code": "INVALID_INPUT",
"message": "Email is required",
"field": "email",
"status": 400
}
}
Include: Error code, clear message, affected field (if applicable), HTTP status code, and optionally a documentation link.
When to Use Each Code
200: GET request successful
201: POST created new resource
204: DELETE successful, no content to return
201: POST created new resource
204: DELETE successful, no content to return
401: Not authenticated (login required)
403: Authenticated but not authorized (permission denied)
403: Authenticated but not authorized (permission denied)
500: Generic server error
502: Bad gateway (upstream server error)
503: Service temporarily unavailable (maintenance)
502: Bad gateway (upstream server error)
503: Service temporarily unavailable (maintenance)