The error 413 Request Entity Too Large is a common issue faced by Odoo users and developers when trying to upload large attachments or restore a database. This error occurs when the size of the uploaded file exceeds the allowed limit set on the server side.
When Does Error 413 Occur?
The most common scenarios in which this error occurs include:
- Uploading documents, images, or other attachments to the Odoo system.
- Restoring a database through the Odoo interface.
Who can return this error?
- Web server: Returns the error if the size of the uploaded file exceeds the limit set in its configuration. For example, in Nginx, the issue can be resolved by adding or increasing the following parameter in the configuration file:
nginx_client_max_body_size 512M; # Increase limit to 512 MB
- After this, you need to restart the web server.
- Odoo: Can also return a 413 error if file size restrictions are set at the application level.
This limitation itself is the problem.
However, resolving this issue often causes difficulties for both users and developers.
This problem occurs periodically, and there are already pages on the official Odoo forum and even in the GitHub repository that describe the issue, discuss it, and suggest possible solutions. However, before you rush to implement these solutions, Kodershop ERP offers a much easier option!
The file size limit in Odoo is stored in the DEFAULT_MAX_CONTENT_LENGTH variable, which is located in the ir_http.py file. This is not the most appropriate way to store such important values, as users have to edit the source code in order to change the limit.
The solution to the problem is simply a recommendation for the user to modify the value directly in the Odoo source code.
However, after digging deeper into the code, we found that Odoo checks the system parameters for the file size limit using the key web.max_file_upload_size, which is not created by default. As a result, Odoo falls back to using the value of the DEFAULT_MAX_CONTENT_LENGTH variable.
max_file_upload_size = int(IrConfigSudo.get_param(
'web.max_file_upload_size',
default=DEFAULT_MAX_CONTENT_LENGTH,
))
Therefore, the solution can be simplified. There is no need to edit the Odoo source files. Instead, you can simply log in with admin rights,
Go to Settings - Technical - System Parameters, and create the parameter web.max_file_upload_size with the desired value.
The value must be specified in bytes.
For example, the default value of 128 MB is 128 * 1024 * 1024 = 134217728
If you need to change it to, for example, 512 MB (512 * 1024 * 1024) you should specify 536870912
We hope you found this information useful.
If you need help with Odoo, please write to us in our LiveChat.