menu

Questions & Answers

How to resolve the Dokku 413 Request Entity Too Large error?

I'm using Dokku to run a node API and recently hit the 413 Request Entity Too Large error when trying to upload a file ~1.5mb.

I've followed the Dokku Nginx docs and created a nginx.conf.d folder in the root of my project with upload.conf file that contains on entry - client_max_body_size 20M;

My understanding; this should modify your Nginx config next time you git push the app, but it is not working for me. What am I missing?

Comments:
2023-01-25 00:05:03
Check nginx.conf.d and nginx.conf permissions (must be to dokku:dokku), check if nginx.conf contain the line include /home/dokku/myapp/nginx.conf.d/*.conf; and/or finally try to manually restart nginx.
Answers(3) :

Since Dokku 0.23.0 you can set it natively with:

dokku nginx:set node-js-app client-max-body-size 50m

Documentation:

https://dokku.com/docs/networking/proxies/nginx/#specifying-a-custom-client_max_body_size

It was my misunderstanding, you have to SSH to the server and execute the following as root:

mkdir /home/dokku/myapp/nginx.conf.d/
echo 'client_max_body_size 50M;' > /home/dokku/myapp/nginx.conf.d/upload.conf
chown dokku:dokku /home/dokku/myapp/nginx.conf.d/upload.conf
service nginx reload

Replace myapp with your app name

You can use the Nginx-Max-Body-Size plugin. It also adds the client_max_body_size directive, and you can control it using a configuration variable:

dokku config:set MAX_UPLOAD_SIZE=20M