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.
| Where | What 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 --fail | curl: (22) The requested URL returned error: 417 |
| Python urllib | urllib.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 HttpWebRequest | The remote server returned an error: (417) Expectation Failed. |
| Apache httpd error page | The 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.
- 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.
In curl, add -H "Expect:" to the command.
In PHP, add 'Expect:' to the CURLOPT_HTTPHEADER array.
In .NET, set ServicePointManager.Expect100Continue = false, or ExpectContinue = false on HttpClient headers.
In other clients, delete the Expect header from your code or SDK settings.
- 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" - Site owners
Accept 100-continue on your server or proxy
Applies when your own server or proxy refuses clients you do not control.
Replace Squid 2.7 or 3.1, or set ignore_expect_100 on in squid.conf.
Move lighttpd to 1.4.46 or later, the first release that supports the handshake.
In Node.js, add a checkExpectation listener if clients send other expectations.
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.
Upgrade curl older than 7.69.0, which sent the header for POST bodies over 1,024 bytes and never retried.
Do not type the header into scripts by hand; curl then repeats it on every retry.
Test S3 uploads on any new endpoint or proxy; botocore sends the header on PUT and POST with file-like bodies.
Prefer HTTP/2 for uploads where the server offers it; curl skips the handshake there.
Stick to the one defined expectation; by default Go, Node.js and Apache servers refuse any other value.
Related errors
Learn more
FAQ
A proxy password you can replace
curl -v logs carry your proxy login; a new password deactivates the old one.


