413 Request Entity Too Large

nutntion 1 Reputation point
2022-07-28T15:26:36.987+00:00

Hi all,

I have an application deployed on IIS, but I found that I can't upload anything larger than 50kb, If I upload more than 50kb I will get this error.

"Error in HTTP request, received HTTP status 413 (Request Entity Too Large)"

Internet Information Services
{count} votes

2 answers

Sort by: Most helpful
  1. charlie arehart 30 Reputation points
    2023-03-17T02:31:10.4133333+00:00

    While the answer about uploadReadAheadSize may well work for some, I was helping folks for whom it did NOT help: they were trying to upload a 30m file, and even raising that uploadReadAheadSize (at the server level) from its default of 50k (49152) to 50m (adding 3 0's) did not stop the 413 error. (I confirmed there was not a lower-level setting overriding the server-level settings.)

    So I proposed instead that they change the Request Filtering feature for "Maximum allowed content length (Bytes)" from its default of 30m (30 000 000) to 40m, and now the upload worked!

    The easiest way to set this is in the IIS UI, go to Request Filtering, then on the right choose "Edit Feature Settings", to see that setting. Or if you may want to look for or edit in web.config or applicationhost.config, the setting is ultimately within these xml entries (beware you may not be able just "drop this in", of course), and I show setting it to 40m. You should choose a value to suit your needs:

    <system.webServer>
    <security>
    <requestFiltering>
    <requestLimits maxAllowedContentLength="40000000" />
    </requestFiltering>
    </security>
    </system.webServer>

    BTW, I tried to put that in the "code" feature of this editor, but it kept dropping all but the first line of the XML, so I have dropped it in as text.

    
    
    5 people found this answer helpful.

  2. Yurong Dai-MSFT 2,826 Reputation points Microsoft Vendor
    2022-07-29T01:53:28.057+00:00

    Hi @nutntion ,

    IIS has a limit for the size of the files users can upload to an application. If the file size exceeds the limit, the application will throw “Error in HTTP request, received HTTP status 413 (Request Entity Too Large)” error.

    The default file upload size is 49 KB (49152 bytes). The application records the log below if user tries to upload a file that is bigger than this size.

    225982-image.png

    The reason for this issue with SSL sites is that the request body must be preloaded during the SSL handshake process.

    Solution
    The quickest solution is to increase the upload size limit. IIS uses uploadReadAheadSize parameter in applicationHost.config and web.config files to control this limit.

    uploadReadAheadSize
    Optional uint attribute.
    Specifies the number of bytes that a Web server will read into a buffer and pass to an ISAPI extension or module. This occurs once per client request. The ISAPI extension or module receives any additional data directly from the client. The value must be between 0 and 2147483647.
    The default value is 49152.
    Server Runtime

    Steps to change the value of this parameter:

    1. Open IIS Manager
    2. Select the site
    3. Double click “Configuration Editor”
    4. Select system.webServer and then serverRuntime
    5. Modify the uploadReadAheadSize value
    6. Click “Apply”

    225966-image.png

    You may also want to change maxRequestEntityAllowed parameter. It specifies the maximum number of bytes allowed in the request body.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,
    Yurong Dai

    4 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.