417

HTTP 417 Expectation Failed

4xx Client Error

4xx Client Error RFC 7231, Section 6.5.14

What is HTTP 417 Expectation Failed?

The 417 (Expectation Failed) status code indicates that the expectation given in the request's Expect header field could not be met by at least one of the inbound servers. This is most commonly seen when using Expect: 100-continue and the server decides not to accept the request based on the headers.

Common Use Cases

  • Server rejecting Expect: 100-continue
  • Proxy server unable to meet client expectations

Usage Example

When a client sends Expect: 100-continue but the server determines from the headers alone that the request will fail (e.g., authentication is invalid or content type is wrong), return 417 Expectation Failed instead of 100 Continue. This saves the client from uploading a body that will be rejected.

// PHP - rejecting a request at the Expect: 100-continue stage
if ($_SERVER['HTTP_EXPECT'] === '100-continue' && !isAuthenticated()) {
    http_response_code(417);
    echo json_encode(['error' => 'Authentication required']);
    exit;
}
Last updated: 21 Jun 2026