What Is a 417 Status Code?

The expectation given in the request’s Expect header field1 could not be met by at least one of the inbound servers.


417 CODE REFERENCES

Rails HTTP Status Symbol :expectation_failed

Go HTTP Status Constant http.StatusExpectationFailed

Symfony HTTP Status Constant Response::HTTP_EXPECTATION_FAILED

Python2 HTTP Status Constant httplib.EXPECTATION_FAILED

Python3+ HTTP Status Constant http.client.EXPECTATION_FAILED

Python3.5+ HTTP Status Constant http.HTTPStatus.EXPECTATION_FAILED

When is a 417 status code used?

The HTTP 417 status code is used when a client specifies one or more conditions for proactive negotiation in the request’s Expect header.

The 417 Expectation Failed error code is only returned when the server or response chain does not support expectations. If the message is received, the client can resend the request with the Expect header.

It’s also related to the HTTP response 100 Continue. The server will examine relevant request details when a request is submitted through the Expect 100-continue header. The server will return the 100 Continue response if it accepts the message body.

If the server doesn’t accept the request, it can send the 401 Unauthorized or 405 Method Not Allowed status.

Status code 417 special considerations

There are a few special considerations that you should keep in mind when it comes to how servers and clients respond to 417 codes and 100 Continue headers.

Servers

Servers must ignore Expect: 100-continue header that is part of a HTTP/1.0 request. Servers also don’t need to acknowledge 100 Continue headers if it already received the message body.

Clients

Clients that send a Expect: 100-continue header does not need to wait for a required period of time. As a result, clients can transmit the message body without receiving a response first.

Will search engines index a URL with a 417 status code error?

No, search engines, like Google, will not index a URL with the HTTP 417 Expectation Failed error. As a result, URLs returning a 417 status error could experience a loss in search result rankings.

417 status code example

Want to see a 417 Expectation Failed response in action? Let’s take a look at an example.

In this example, a client requests to send a pdf article and the server responds with the 417 error.

Request

HTTP/1:1

Host: www.example.com

Content-type: pdf

Content-length: 5000

Expect: 100-continue

Response

HTTP/1:1 417 Expectation Failed

Content-type: Text

Content length: 100

<html>

<head>

<title> Expectations not supported </title>

<head>

<body>

<p> Can’t support your request </p>

<body>

</html>

Additional resources


Return to List of HTTP Status Codes

TO TOP