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.

12 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.

Leave a Reply

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