Web Server Response Codes

This article provides a structured overview of the most common HTTP response codes generated by web servers. These status codes indicate the outcome of a client's request and can help identify issues or required actions when troubleshooting. Most server-generated codes are related to the server environment rather than specific application logic. Each section below groups response codes by category and offers a description along with recommended actions for users or administrators.

 

4xx: Client Error Responses

These codes indicate that the client has made an error in the request. They typically require the client to modify the request before resubmitting.

400 Bad Request

Description: The server could not understand the request due to malformed syntax.
Recommended Action: Review and correct the request formatting or data. Ensure the request meets the API or resource requirements before retrying.

401 Unauthorized

Description: Authentication is required to access the resource.
Recommended Action: Provide valid authentication credentials. If credentials have already been supplied, verify their accuracy and permissions.

403 Forbidden

Description: The server understands the request but refuses to authorize it.
Recommended Action: Do not retry the request unless you have received new permissions. Check user roles and server-side access controls.

404 Not Found

Description: The requested resource could not be found.
Recommended Action: Confirm the URL or resource identifier is correct. If the resource was recently moved or deleted, update any references.

405 Method Not Allowed

Description: The HTTP method used is not allowed for the resource.
Recommended Action: Check the allowed methods for the resource (as indicated in the response's Allow header) and adjust the request accordingly.

406 Not Acceptable

Description: The resource cannot generate content acceptable according to the request's Accept headers.
Recommended Action: Adjust the Accept headers to request a supported content type or consult the response for a list of supported types.

407 Proxy Authentication Required

Description: Authentication with a proxy server is required.
Recommended Action: Supply valid proxy authentication details as indicated in the Proxy-Authenticate header.

408 Request Timeout

Description: The client took too long to send the request.
Recommended Action: Try resubmitting the request. Investigate network latency if this occurs repeatedly.

409 Conflict

Description: The request conflicts with the current state of the resource.
Recommended Action: Review the response details to resolve the conflict, such as updating your data to match the server's state before retrying.

410 Gone

Description: The resource is no longer available and has been intentionally removed.
Recommended Action: Remove or update references to the resource. Do not expect the resource to become available again.

411 Length Required

Description: The server requires a Content-Length header.
Recommended Action: Include a valid Content-Length header in the request before retrying.

412 Precondition Failed

Description: Request conditions specified in headers were not met.
Recommended Action: Review and revise any precondition headers (like If-Match or If-Unmodified-Since) and try again.

413 Request Entity Too Large

Description: The request is larger than the server is willing to process.
Recommended Action: Reduce the size of the request payload. If the server specifies a Retry-After header, wait before retrying.

414 Request-URI Too Long

Description: The URI provided is too long for the server to process.
Recommended Action: Shorten the URI, possibly by converting GET requests with long query strings to POST requests with body data.

415 Unsupported Media Type

Description: The request entity has a media type not supported by the server.
Recommended Action: Change the Content-Type header to a supported format.

416 Requested Range Not Satisfiable

Description: The requested byte range is not available for the resource.
Recommended Action: Adjust the requested range to fall within the bounds of the resource.

417 Expectation Failed

Description: The server cannot meet the requirements of the Expect request-header field.
Recommended Action: Remove the Expect header or adjust its value and try again.

 

5xx: Server Error Responses

These codes indicate that the server failed to fulfill a valid request due to internal issues.

500 Internal Server Error

Description: An unexpected server error occurred.
Recommended Action: Check server logs for diagnostic information. If you have no access, contact the server administrator.

502 Bad Gateway

Description: The server received an invalid response from an upstream server.
Recommended Action: Check the status and configuration of upstream servers or third-party services.

503 Service Unavailable

Description: The server is temporarily unable to handle requests due to overload or maintenance.
Recommended Action: Wait and retry after some time. If provided, use the Retry-After header to determine when to retry.

504 Gateway Timeout

Description: The server did not receive a timely response from an upstream server.
Recommended Action: Investigate network issues or the status of upstream services. Retry the request after resolving any issues.

505 HTTP Version Not Supported

Description: The server does not support the HTTP protocol version used in the request.
Recommended Action: Use a supported HTTP version as indicated in the server's response.

 

Additional Notes

  • Error Handling: When encountering any error code, carefully review any message or details provided in the response body or headers for further guidance.
  • Logs and Diagnostics: For server-side errors (5xx), error logs are essential for troubleshooting.
  • Documentation: Reference your application's or API's documentation for permitted methods, supported content types, and specific requirements.

By understanding and responding appropriately to these HTTP response codes, administrators and users can more effectively diagnose issues and ensure smoother operation of web services and applications.

×