Cannot read configuration file because it exceeds the maximum file size on SharePoint Server

After the installation of SharePoint updates you might be getting this error on one or multiple sharepoint sites including Central Administration. It is because web.config file of one or more IIS sites has grown beyond the default limit.

You can change this limit manually in the registry:


Add or update the following DWORD entry: MaxWebConfigFileSizeInKB
The value has to be higher than the current size of your largest web.config file. The change takes effect after IIS reset.

Get the current value using PowerShell:
Get-Item HKLM:\SOFTWARE\Microsoft\InetStp\Configuration
Set a custom value using PowerShell:
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp\Configuration -Name MaxWebConfigFileSizeInKB -Value 1200

Beyond 900 KB…

SharePoint updates for SP 2016, 2019 and Subscription Edition automatically set this registry key value to 900 KB during the installation . If you set the registry value to more than 900 KB, the next SharePoint update resets it back o 900 KB.

Reducing the web.config size:

You may be able to reduce the web.config file size. Microsoft has created a script to remove duplicates added by psconfig.exe or psconfigui.exe to the web.config file. This action is preferable because a large web.config file may affect performance. Check out the article below where you can find more about it.

GitHub Script:

SharePoint/Remove-DuplicateAuthorizedTypeEntryFromWebConfig.ps1 at main · joeric2/SharePoint · GitHub

Related Articles

Leave a Reply

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