How to Avoid Request Entity Too Large 413 Error

How to solve 413 request entity too large

You have to modify your .platform as shown in the docs.

For example, you could have the following .platform/nginx/conf.d/myconfig.conf with content:

client_max_body_size 20M;

response: 413 Request Entity Too Large

There are two limits you need to change. Kestrel and IIS.

You can change the MaxRequestBodySize limit of Kestrel in Program.cs.

public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = long.MaxValue;
})
.UseIISIntegration()
.Build();
}

And the limit for IIS can be changed in web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
</configuration>

Why does happen request entity too large error?

When the web server that is running a website that you are trying to access decides that the HTTP data stream that your web browser is sending to it is too large (in this context, “too large” means that the data stream has way too many bytes), it will not cope with it and issue error 413.

How to fix '413 Request Entity Too Large' error in Node.js

The problem ended up not being nginx at all, I was trying to email the images as attachments via Mailgun and that has a hard limit of 25MB.

After editing this line in the section where users can upload images everything works perfectly:

let result = await cloudinary.v2.uploader.upload(file.path, {width: 1280, height: 720, crop: "limit"});

The remote server returned an error: (413) Request Entity Too Large

I've eventually managed to get this working after several hours of head scratching. I removed the binding name "BasicHttpBinding_BailiffServices" from both the <binding /> element and the <endpoint /> elements. I stumbled across this solution on the MSDN site. Hope this helps someone else.



Related Topics



Leave a reply



Submit