Skip to content

417 Expectation Failed — Meaning, Common Causes & How to Fix

417 4xx Client Error RFC 9110 §15.5.18

417 Expectation Failed means: The server cannot meet the expectation set by the Expect request header — almost always Expect: 100-continue. The client should retry without the expectation; the code exists so the handshake fails fast instead of stalling. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 417 when a proxy or origin does not understand expect: 100-continue; an old http/1.0 server receives an http/1.1 expectation; a middleware strips or mishandles the expect header. On the client side, remove the Expect header and send the body directly (curl: -H 'Expect:'); most libraries let you disable 100-continue behavior. On the server side, support Expect: 100-continue properly or answer 417 immediately; never silently ignore it — that causes one-second client stalls.

Advertisement
Ad slot · ref-top

When 417 happens

  • A proxy or origin does not understand Expect: 100-continue
  • An old HTTP/1.0 server receives an HTTP/1.1 expectation
  • A middleware strips or mishandles the Expect header

How to fix it

On the client

Remove the Expect header and send the body directly (curl: -H 'Expect:'); most libraries let you disable 100-continue behavior.

On the server

Support Expect: 100-continue properly or answer 417 immediately; never silently ignore it — that causes one-second client stalls.

Should you retry?

Not retryable as-is: change the request (credentials, payload, URL) first.

Debugging steps

When 417 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: a proxy or origin does not understand expect: 100-continue. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

417 exists so the Expect handshake fails fast instead of stalling: a server that silently ignores Expect: 100-continue causes a one-second client delay, which is worse than an explicit refusal.

Examples

Raw HTTP
HTTP/1.1 417 Expectation Failed
Content-Type: application/json
Content-Length: 110

{
  "error": "expectation_failed",
  "message": "A proxy or origin does not understand Expect: 100-continue"
}
curl
curl -i https://api.example.com/v1/resource   # observe the 417 response and its headers
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 417) {
  const problem = await res.json(); // read field-level details
  // fix the request (credentials, payload, URL) — identical retries keep failing
  throw new RequestError(problem);
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 417:
    problem = res.json()  # field-level error details
    # correct the request before retrying — identical retries keep failing
    raise RequestProblem(problem)

Frequently asked questions

Why does curl add Expect: 100-continue?

For bodies over 1 KB curl asks permission before uploading, avoiding wasted bandwidth if the server would reject the request. Servers that ignore it cause a 1-second delay.

Is 417 common today?

Rare — most modern stacks handle 100-continue. You will meet it with legacy servers, some embedded devices, and misconfigured proxies.

Are 4xx errors always the client's fault?

By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.

Should I retry 4xx responses automatically?

Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →