Solve '413 Request Entity Too Large' error

If you are self-hosted, you may run into an issue when attempting to upload a data set to the WorkBench that is larger than your server is configured to handle.

This is because many data sets are larger than the default size allowed by nginx.

You may see the following error:

413 Request Entity Too Large

This is being displayed becuase of the web server, not Specify.

It happens because the size of the data set you are trying to import is larger than 1MB.

You can change that limit to something like 500M (500 megabytes) by following this guide:

Nginx: 413 – Request Entity Too Large Error and Solution

In short, you need to add the client_max_body_size 500M; line in nginx.conf file and restart the nginx container.

We faced the issue using the just-specify7 docker compose. We (i) edited /docker-compositions/just-specify7/nginx/specify.conf
and (ii) added the client_max_body_size option, as suggested.

server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx;
    client_max_body_size 512M;

    location /static/ {
    ...

Then (iii) restarted the container. Is is the correct way to fix the error for docker self-hosted installation ?

Nonetheless, after doing so, we still get 413 Request Entity Too Large error with file uploaded in the workbench ~30Mb. With ~5 Mb files, it is OK, no error is thrown. But we are far from the 512 Mb limit set to the nginx server. What else could be at stake that would explain the error ? The hosting machine itself ?

Hi @pverley,

Can you ensure the nginx container has been completely restarted so the previous volume is destroyed? You can also enter into the container via the terminal to see if the file inside the volume under the nginx service is changed.

Thanks.
I stopped all containers, did prune all containers and images before I restarted the just-specify7 compose file (updated to v7.9.5). Then:

docker exec just-specify7-nginx-1 cat /etc/nginx/conf.d/default.conf
server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx;
    client_max_body_size 512M;

    location /static/ {
   ...

The 512M parameter is changed successfully. Then I tried a new 23Mb upload from the workbench and running docker logs -f on every running services (sp7, sp7-worker, nginx, redis, etc.). Issue is still triggered and here is the only logs I got from nginx related to the upload:

##.###.33.33 - - [22/May/2024:20:11:51 +0000] "GET /notifications/messages/?since=2024-5-22+22%3A11%3A50 HTTP/1.1" 200 2 "https://specify.herbier-guyane.fr/specify/workbench/import/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" "##.###.35.14"
##.###.33.33 - - [22/May/2024:20:11:52 +0000] "GET /notifications/messages/?since=2024-5-22+22%3A11%3A52 HTTP/1.1" 200 2 "https://specify.herbier-guyane.fr/specify/workbench/import/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" "##.###.35.14"

I do not really know how to monitor the upload and check where/why it fails.

After discussion with Network IT staff from my institute, we understood that it was a limitation from the reverse-proxy that triggered the error, not the ningx container!