What Is a 413 Status Code?

The server is refusing to process a request because the request payload is larger than the server is willing or able to process.

The server MAY close the connection to prevent the client from continuing the request.

If the condition is temporary, the server SHOULD generate a Retry-After header field to indicate that it is temporary and after what time the client MAY try again.


Rails HTTP Status Symbol :request_entity_too_large

Go HTTP Status Constant http.StatusRequestEntityTooLarge

Symfony HTTP Status Constant Response::HTTP_REQUEST_ENTITY_TOO_LARGE

Python2 HTTP Status Constant httplib.REQUEST_ENTITY_TOO_LARGE

Python3+ HTTP Status Constant http.client.REQUEST_ENTITY_TOO_LARGE

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

.NET HttpStatusCode.RequestEntityTooLarge

Rust http::StatusCode::PAYLOAD_TOO_LARGE

Java java.net.HttpURLConnection.HTTP_ENTITY_TOO_LARGE

Apache HttpComponents Core org.apache.hc.core5.http.HttpStatus.SC_REQUEST_TOO_LONG

Angular @angular/common/http/HttpStatusCode.PayloadTooLarge

What causes a 413 status code?

A 413 status code can happen for a few reasons, including:

  • Request entity too large: The most common cause of a 413 status code is a request entity that is too large for the server to handle.
  • Server configuration limits: The server may have a limit on the size of the request entity set in the server software or configuration file.
  • Network issues: Slow or unstable network connections can cause large request entities to time out or fail.
  • Content Delivery Networks (CDNs): CDNs may have their own limits on the size of request entities they can handle.

How to troubleshoot a 413 status code

If you encounter a 413 status code and need to troubleshoot it, consider the following:

  • Analyze server logs: Server logs can provide valuable information about the cause of a 413 status code. Look for any error messages related to request entity size or configuration limits.
  • Check network configuration: If the issue is related to network connectivity, check the network configuration for any issues or bottlenecks.
  • Review CDN settings: If a CDN is being used, review its settings to ensure it can handle large request entities.
  • Optimize website or application: If the issue is persistent, consider optimizing the website or application to reduce the size of request entities or improve performance.

3+ best practices for the 413 HTTP status code

Prevent the 413 HTTP status code with these best practices:

  1. Set appropriate request limits: It’s essential to set reasonable limits on request entity size based on the server’s available resources and expected usage. This can prevent requests from being rejected due to a large request entity.
  2. Implement caching mechanisms: Caching can help reduce the size of request entities and improve server performance. By caching frequently requested data, the server can quickly retrieve it instead of processing a large request entity every time.
  3. Compress data before sending: Compressing request entities can significantly reduce their size without sacrificing data quality. This can help avoid a 413 status code while improving overall performance.
  4. Use CDNs: CDNs can help distribute the load of large requests across multiple servers, preventing a 413 status code from occurring. Additionally, CDNs may have their own limits on request entity size, which can help ensure optimal performance.

Additional resources

Return to List of HTTP Status Codes