Geonode logo
Website and server errors

How to Fix 417 Expectation Failed

Find which hop refused your Expect header, then apply three ranked fixes, one with cURL, Python and Node.js code.

Updated

TL;DR

417 Expectation Failed means a server or proxy on the route could not meet the Expect header in your request, usually Expect: 100-continue, which curl and some other clients add to large uploads. The fastest fix is to resend without that header, in curl with -H "Expect:".

What a 417 looks like in each client

The status line is the same everywhere; each client wraps it in its own words.

WhereWhat you see
curl -v< HTTP/1.1 417 Expectation Failed
curl 8.3 or later with -v, before its automatic retry* Got HTTP failure 417 while waiting for a 100
curl --failcurl: (22) The requested URL returned error: 417
Python urlliburllib.error.HTTPError: HTTP Error 417: Expectation Failed
Python requests, raise_for_status()requests.exceptions.HTTPError: 417 Client Error: Expectation Failed for url: http://example.com/upload
.NET HttpWebRequestThe remote server returned an error: (417) Expectation Failed.
Apache httpd error pageThe expectation given in the Expect request-header field could not be met by this server.

Why this happens

Your client asked for a go-ahead before uploading, and one server on the route refused.

curl adds Expect: 100-continue to bodies over 1 MB or of unknown size, and .NET's HttpWebRequest to POST and PUT requests with a body. Any hop too old for the handshake, such as an HTTP/1.0 server, turns the request down.

Diagnose your 417 first

Five checks that separate client, proxy and application causes; the first needs no terminal.

  • Compare what passes with what fails; if small requests work and large uploads do not, an automatic header is the likely trigger.

  • Repeat the request with curl -v; if an Expect line sits among the > lines before the 417, that header is what was refused.

  • Look for 417 while waiting for a 100 in that output; if present, curl retried by itself, which it skips after Connection: close.

  • With a proxy set, check the URL scheme; for http:// the proxy reads your headers and can refuse by itself, while https:// is tunneled.

  • Read the response body; a message there, with no such header sent, means the app reuses the code for its own errors, as Frappe does.

Solutions ranked by effectiveness

Start with the client; the last fix is for whoever runs the server or proxy.

  1. Most common fix

    Send the request without Expect

    Applies when your client added the header on its own. The body then goes out at once, as browsers send it, and nothing waits for a go-ahead.

    1. In curl, add -H "Expect:" to the command.

    2. In PHP, add 'Expect:' to the CURLOPT_HTTPHEADER array.

    3. In .NET, set ServicePointManager.Expect100Continue = false, or ExpectContinue = false on HttpClient headers.

    4. In other clients, delete the Expect header from your code or SDK settings.

  2. For developers

    Resend without Expect after a 417

    Applies when you want to keep the header for servers that honor it. RFC 9110 says a client that receives this status should repeat the request without the expectation; each snippet does that once.

    url="http://example.com/upload"
    code=$(curl -s -o /dev/null -w '%{http_code}' -T payload.bin "$url")
    if [ "$code" = "417" ]; then
      code=$(curl -s -o /dev/null -w '%{http_code}' -H "Expect:" -T payload.bin "$url")
    fi
    echo "$code"
  3. Site owners

    Accept 100-continue on your server or proxy

    Applies when your own server or proxy refuses clients you do not control.

    1. Replace Squid 2.7 or 3.1, or set ignore_expect_100 on in squid.conf.

    2. Move lighttpd to 1.4.46 or later, the first release that supports the handshake.

    3. In Node.js, add a checkExpectation listener if clients send other expectations.

    4. In your own API, return 400 or 422 for validation errors, not 417.

Stop the 417 from coming back

Habits for upload scripts and API clients that keep this header out of your way.

  1. Upgrade curl older than 7.69.0, which sent the header for POST bodies over 1,024 bytes and never retried.

  2. Do not type the header into scripts by hand; curl then repeats it on every retry.

  3. Test S3 uploads on any new endpoint or proxy; botocore sends the header on PUT and POST with file-like bodies.

  4. Prefer HTTP/2 for uploads where the server offers it; curl skips the handshake there.

  5. Stick to the one defined expectation; by default Go, Node.js and Apache servers refuse any other value.

Check who sent the replyGeonode's error reference describes its gateway's own status codes; compare your reply with it.
Try residential proxies

Related errors

Learn more

FAQ

It means a server along the way would not honor the expectation your request stated. HTTP defines a single one, a go-ahead reply before the body is sent, so that exchange is what failed.

Take the Expect header out and repeat the request; curl, PHP and .NET each have a switch for it. If you never sent one, the application chose this code itself, so read the response body.

It is a request header that asks the server to answer 100 Continue before the client starts sending the body. A request the server would reject anyway, for example with 401 or 405, then costs no upload.

One second by default, then it sends the body anyway; --expect100-timeout changes the wait. In a local test, a 2 MB POST to a server that ignored the header took 1.01 seconds, and under 0.01 without it.

It belongs to the 4xx client error class, but your request can be valid HTTP. The standard treats such a reply as a sign that the response chain lacks support for the handshake.

Rarely. MDN says none of the common browsers send the Expect header, and page scripts cannot add it, since browsers forbid that header name; Node.js fetch rejects it, with expect header not supported.

A proxy password you can replace

curl -v logs carry your proxy login; a new password deactivates the old one.