Trending issue: “Cannot read configuration file because it exceeds the maximum file size” on SharePoint Server 2013

After installation of recent updates for SharePoint 2013 users may receive an HTTP 500 error with the following additional details:
“Cannot read configuration file because it exceeds the maximum file size”

Cause

IIS has a default limit of 250 KB for web.config files. SharePoint web.config files are quite large even if no customizations are installed. Additional custom components installed on the SharePoint servers can further increase the web.config files. Some SharePoint security fixes also add additional entries to web.config to ensure that built-in functionality is not affected by restrictions implemented in the security fixes. All this together can in some cases increase the web.config files beyond the 250 KB limit.

Resolution

To prevent or resolve this issue the following entry should be added or updated in the registry:
(make a backup of the registry before proceeding)

Under the following key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Configuration\

add or update the following DWORD entry: MaxWebConfigFileSizeInKB
Ensure that this entry gets the value of 900 (dec) or 384 (hex)

See here for more details:

Newer SharePoint Versions

Newer SharePoint versions (2016, 2019, Subscription Edition) are not affected by this as they as they update this registry key value during the SharePoint installation.

22 Comments


  1. Mahalo Stefan, we saw this a few weeks ago. THat fix did work BTW…

    Reply

    1. Thanks for confirming Kevin!

      Reply

      1. Hi Stefan, Whether this “Trending issue: “Cannot read configuration file because it exceeds the maximum file size” on SharePoint Server 2013” will be resolved in November 2022 CU?

        Reply

        1. Hi Prabhu,
          the amount of entries in the web.config has not been reduced in November CU. So the answer would be no. Also be aware that only SharePoint farms with a large number of custom entries in the web.config should be affected.
          If one of your farms IS affected the workaround listed above to increase the maximum size of the web.config is the solution.
          Cheers,
          Stefan

          Reply

  2. yes.. had the same issue last week with sharepoint.. update web and app servers with same reg key works a treat… thanks you saved our A*s

    Reply

  3. Hi Stefan, we also ran into this. After inspecting the web.config(s) we found a lot af duplicate lines.
    after removing the dupicate lines, the web.config was within the limits.
    the duplicates were in the sections:

    and in:
    <System.Workflow.ComponentModel.WorkflowCompiler>

    first make a copy of the web.config
    open it with NotePad++ (with plugin “Remove Duplicate lines”)
    select only the entry’s of the effected sections ! (no other parts)
    then select remove duplicate lines.
    save the web.config and check the sections.
    compare whitin NotePad++ to see what has changed.
    take the “new” web.config in use (IIS wil do a restart of website)

    Reply

    1. Hi Hans,
      that is interesting. I haven’t seen that.
      Do you have info which lines were duplicated?
      Cheers,
      Stefan

      Reply

      1. under #
        de following lines (i put a # i front because my first post was not complete)

        #
        #

        Reply

        1. next try:
          SafeControl Assembly=”Microsoft.Office.Server.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.Office.Server.Search.Internal.UI” TypeName=”SearchAdministration” Safe=”True” AllowRemoteDesigner=”False”

          Reply

          1. The larger part is under -targetFx version=”v4.0″-
            i wil copy only a part of it…

            authorizedType Assembly=”System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.Activities.Rules” TypeName=”RuleDefinitions” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.Activities.Rules” TypeName=”RuleExpressionCondition” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeBinaryOperatorExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodePrimitiveExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeMethodInvokeExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeMethodReferenceExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeFieldReferenceExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeThisReferenceExpression” Authorized=”True” />
            authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodePropertyReferenceExpression” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”WorkflowCompilerInternal” Authorized=”False” />
            authorizedType Assembly=”System.Workflow.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”WorkflowCompilerInternal” Authorized=”False” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”CallExternalMethodActivity” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”CallExternalMethodActivityValidator” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”CorrelationAliasAttribute” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”CorrelationInitializerAttribute” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”CorrelationParameterAttribute” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”DelayActivity” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”EventDeliveryFailedException” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”EventDrivenActivity” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”EventHandlersActivity” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”EventHandlingScopeActivity” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”EventQueueName” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”ExternalDataEventArgs” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.” TypeName=”ExternalDataExchangeAttribute” Authorized=”True” />
            authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.
            ” TypeName=”ExternalDataExchangeService” Authorized=”True” />


          2. Sorry, but I cannot see any duplication in the config you pasted as the TypeName differs in almost every line. The only duplicate TypeName is WorkflowCompilerInternal, but that is listed with versions 3.0.0.0 and 4.0.0.0, so not a duplicate either.


          3. hi Thomas,
            the fragments i posted above are the lines that are duplicates, and that where removed.
            in the quote there are no duplacates.
            If You have the same problem, try to select 1 of the lines and try to find it in your web.config.
            you should find 1 line but in my case i found duplacates (2 identical lines).
            because it is impossible to search line for line I used Notepad++ with a plugin to remove duplicates.
            the web.config is an XML format, therefore I did a search per section and there were 2 sections with duplicates.
            please look in the section : targetFx version=”v4.0″
            i cannot use the XML lines in this blog , they wil not show.


        2. Did you ever find a solution to your duplicate line problem in the web.config file? I’ve been seeing the problem for years but only now started looking for a solution because now my web.config file is too large and SharePoint application will not work. There were almost 600 duplicate lines in my web.config file.

          Reply

  4. I can confirm that duplicates do exist. The lines at the bottom are taken from web.config file (SharePoint Foundation 2013; content and CA web applications were affected; also experienced in a Server edition) and web application has no custom solutions applied. Those lines can be found 39 times in my case. Most of the duplicates are mentioned 3 times. Removing duplicates just from targetFx section resulted in size reduction from 265223 bytes to 132667. Excel told me that it removed 632 duplicates and left 180 unique lines. Here is the content of the lines:

    authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeBinaryOperatorExpression” Authorized=”True”

    next duplicate:
    authorizedType Assembly=”System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ Namespace=”System.CodeDom” TypeName=”CodeFieldReferenceExpression” Authorized=”True”

    Reply

    1. The removing duplicate lines method worked for me. Using notepad++, I removed the duplicates in web.config between these two lines:
      and

      Reply

  5. Thank you for this! We were on October 2022 patch level (15.0.5493.1000) for our SharePoint 2013 server, and went to update to December 2022 (15.0.5511.1000) and after IIS had these errors. The registry change you provided to allow over 250kb config files fixed our issue.

    Reply

  6. Any updates on what is causing the duplicate entries? Would like to know how to prevent it from happening.

    Reply

  7. Just hit this with SharePoint Server 2019 (!), which should be unaffected per this blog post.

    The respective web.config file is 925 KiB.

    Like Hans Dekker wrote above, also in our case it’s a lot of duplication under:

    configuration>
    System.Workflow.ComponentModel.WorkflowCompiler>
    authorizedTypes>
    targetFx version=”v4.0″>

    Happy to share the file with you, Stefan Goßner, if it helps pinpoint the issue.

    Reply

    1. Grew to 966 KiB with December 2023 CU.

      Reply

  8. Hello Stefan,

    It seems that when your web config exceeds 900 KB and you set the registry value above 900 KB, the next SharePoint update resets it back o 900 KB and you have to set it back to the desired value yourself.

    Best regards
    Jan

    Reply

    1. Hi Jan,
      this is a known issue which is currently under investigation.
      The problem is not the reset to the 900 KB. The problem is that the web.config contains a large number of duplicate entries in the authorizedTypes section which cause the web.config to blow to the large size you see.
      The workaround for now is to remove the duplicate entries till the size is below the threshold.

      Give me a couple of minutes to create a blog post for this with a workaround…
      Cheers,
      Stefan

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.