Example HTTP Response
HTTP/1.1 417 Expectation Failed- Expect: 100-continue not supported
- Server cannot meet client expectations
- Proxy doesn't support expected behavior
What does this mean?
Sorry to disappoint! You expected something the server couldn't deliver. Expectations vs. reality strikes again.
Technical Definition
The expectation given in the Expect request header could not be met by the server.
RFC Says
"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."
Plain English:
417 means 'I can't meet the expectations you set in your Expect header.' The most common use case is with 'Expect: 100-continue', where a client wants to check if the server will accept a large request before sending it. If you return 417, the client shouldn't send the request body.
Common Misinterpretation
This is rarely used in modern APIs. Most developers will never need to handle or return 417. It's specifically for the Expect header mechanism, not for general 'expectations' about how an API should work.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(417).json({
error: 'Expectation Failed',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(417, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Expectation Failed',
message: 'Your error message here'
}));
}).listen(3000);