413 Payload Too Large
HTTP response status code 413 Payload Too Large is a client error that is returned by the server in cases where the client has initiated a request that contains a message body that is larger than the server is willing to accept for processing.
When the 413 Payload Too Large error message is received, it is because the client is sending a request that is too large. A common example is when a client tries to send a file to the server that is of an acceptable type and format but is too long. Pictures, for instance, may be of an unnecessarily high resolution and can be significantly smaller without impacting the intended use. Rather than take on the responsibility of modifying the image files, the server refuses the transfer and relies on the client to do the necessary processing.
In these situations, a client can check for file size allowance in advance of initiating the PUT by using the [[expect|Expect: 100-continue header]. The server will acknowledge and in response, the message body can be sent or not.
The server can optionally send a Retry-After header in the response. If this is the case, the client may attempt the request again after a specified period or specified time and date. For example, if the client has exceeded their upload quota for the week, or large uploads are not allowed during peak hours, the server will suggest that they try again at a more appropriate time.
If the situation occurs because the server is out of storage space then the server shall send the error message 507 Insufficient Storage instead.
The server can include the
Connection: close header to terminate the connection, preventing the client from sending the message body.
Search engines like Google will not index a URL with 413 Payload Too Large response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.
In the example, the client attempts to send a file and the server responds with 413 Payload Too Large because there is a lot of traffic at the moment. In response, the server denies the request, closes the connection, and suggests that the client try again after 30 minutes.
PUT /docs HTTP/1.1 Host: www.example.re Content-Type: applications/pdf Content-Length: 10000
HTTP/1.1 413 Payload Too Large Retry-After: 1800 Connection: close Content-Type: text/html Content-Length: 202 <html> <head> <title>File Too Large</title> </head> <body> <p>There is too much server traffic to accept your transfer at this time. Please try again after 30 minutes.</p> </body> </html>
Apache HttpComponents Core
The 413 Payload Too Large status code is a client error that is returned when a message-body is too large for the server to process. The connection may be closed, and the client may receive a Retry-After header if the problem is temporary.