By using AWS re:Post, you agree to the Terms of Use

AWS API Gateway 413 Request Entity Too Large on response size (NOT request payload) greater than 10MB


Recently, one of our AWS API Gateway HTTP APIs has started failing with HTTP status code 413 and a message "Request Entity Too Large" when the API returns a stream of data (like a PDF file for example) of size greater than 10MB.

The AWS API Gateway HTTP APIs documentation mentions a limit of 10 MB but that's only for the request payload and there's no mention of a limit for the response size.

Our API has also been working fine with responses of size greater than 10 MB for a long time but has suddenly started failing recently.

Has there been any recent change in API Gateway HTTP APIs ? Is this a new limitation that has been added ?

1 Answer

The 10 GB limit applies to both the request payload and to the response payload. The documentation talks about Resource or Operation limit. I have no idea how it worked before. Are you sure it was larger than 10 MB?

In either case, there are two options around it:

  1. Use compression. This will help in some case, but may break again if the returned object is > 10 MB also after compression.
  2. Store the object in S3 and return a pre-signed URL to the client (it can be returned in a redirect response).
profile picture
answered 6 days ago
  • I'm quite positive that it used to work before. We used to run file download stress tests with a script that made several requests to download different files with sizes between 20MB to 100MB and it used to work quite well.

    I also don't doubt that the requests made by the script went via API Gateway since it's our only entry point. The other entry point is a private load balancer so that's ruled out.

    Furthermore, I checked with users of our application and they confirmed that they were able to download files >10MB before.

    I have also ruled out any issues in our application because there was no release performed recently and I was also able to replicate the issue by adding a dummy route in API gateway pointing to a random 15MB pdf file on the internet.

    So I still feel it's quite possible that something probably has changed in API gateway but it's a shame we can't really know for sure.

    Anyway, we were able to get around this issue by creating a public load balancer and moving this one particular API to it. Thanks for your suggestions.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions