417 Expectation Failed
The expectation given in the Expect request header field cannot be met.
Usually happens because:
- ☑ Inbound proxy servers unable to comply with Expect
- ☑ Unsupported custom expectation header properties.
🔍 Quick Checklist:
Meaning
The HTTP 417 Expectation Failed client error status code indicates that the expectation given in the Expect request header field cannot be met by at least one of the inbound servers (origin or proxies).
Root Causes
- Inbound proxy servers unable to comply with Expect: 100-continue request parameters.
- Unsupported custom expectation header properties.
| Cause | Frequency |
|---|---|
| Inbound proxy servers unable to comply with Expect | ⭐⭐⭐⭐⭐ |
| Unsupported custom expectation header properties. | ⭐⭐⭐⭐ |
Common Mistakes
- Sending custom Expect values that are unrecognized by proxy servers.
- Failing to retry upload streams without Expect headers upon receiving 417.
How to Fix
Framework-Specific Examples
Handling unfulfilled Expect headers in Express.
app.post('/upload', (req, res) => {
if (req.headers.expect === 'custom-value') {
return res.status(417).send('Expectation Failed');
}
});Server Configuration Examples
Nginx passes expect headers downstream to app servers.
# Expect configurationsPrevention
- Only use standard HTTP Expect headers (e.g. Expect: 100-continue).
Frequently Asked Questions (FAQ)
Q: Why is 417 Expectation Failed triggered?
It is triggered when the client sends an 'Expect' header (like Expect: 100-continue) and a proxy or server in the connection path cannot meet that expectation.
Q: What is the most common expectation?
The only standard HTTP expectation defined is '100-continue', which asks the server to verify headers before the client sends the payload body.
Q: Can I bypass a 417 error on the client?
Yes. If a client receives a 417 error, it should retry the request immediately without sending the 'Expect' header.
Q: Is 417 cacheable?
No. 417 Expectation Failed responses are never cached.