djangowebserverhttp-status-code-413

413 Payload Too Large on Django server


My team has been getting 413 errors whenever we try and upload large files to our Django back-end: 413 Payload too large

We can't exactly pin down the maximum acceptable file size - it seems to vacillate in the 1-3MB range.

Things we have excluded:

Can anyone spot what we're missing?


Solution

  • Django has a build in mechanism to prevent any suspicious activity.

    In your settings.py file set the variable

    DATA_UPLOAD_MAX_MEMORY_SIZE = 10*1024*1024  # your size limit in bytes
    

    See documentation: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-DATA_UPLOAD_MAX_MEMORY_SIZE