How to Fix "Payload Too Large (413)" Error in Windows Server

Users may encounter a "Payload Too Large (413)" error when trying to upload large files to a web server running on Windows.

This error typically occurs when the file size exceeds the limit set for uploads in the server configuration.

Resolution:

Step 1: Edit the Application Host Configuration File

  1. Open Notepad with administrative privileges.
  2. Open the file located at C:\Windows\System32\inetsrv\config\applicationHost.config.

Note: Be cautious while editing this file as incorrect changes can cause server issues.

Step 2: Modify the UploadReadAheadSize Setting

  1. Run the following command in the Command Prompt with administrative privileges:
    appcmd.exe set config -section:system.webserver/serverruntime /uploadreadaheadsize:1048576 /commit:apphost
  2. This command sets the uploadReadAheadSize to 1048576 bytes (1 MB). Adjust the value as needed based on your requirements.

Step 3: Restart the Web Server

  1. Restart the web server for the changes to take effect.

Additional Information:

  • This resolution applies to Windows Server environments.
  • The uploadReadAheadSize parameter defines the number of bytes a Web server will read in advance and is essential for handling large uploads.
  • Always back up the applicationHost.config file before making any changes.