Deploy failed - PayloadTooLargeError: request entity too large

Hi !

When I want to deploy my flow I have this error. I think it's because my flow is too important.
Do you have a solution ?
Ty by advance

Deploy failed:
PayloadTooLargeError: request entity too large
    at readStream (/usr/share/myapp/nodejs/node_modules/raw-body/index.js:155:17)
    at getRawBody (/usr/share/myapp/nodejs/node_modules/raw-body/index.js:108:12)
    at read (/usr/share/myapp/nodejs/node_modules/body-parser/lib/read.js:77:3)
    at jsonParser (/usr/share/myapp/nodejs/node_modules/body-parser/lib/types/json.js:135:5)
    at Layer.handle [as handle_request] (/usr/share/myapp/nodejs/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:317:13)
    at /usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:275:10)
    at urlencodedParser (/usr/share/myapp/nodejs/node_modules/body-parser/lib/types/urlencoded.js:100:7)
    at Layer.handle [as handle_request] (/usr/share/myapp/nodejs/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:317:13)
    at /usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/share/myapp/nodejs/node_modules/express/lib/router/index.js:275:10)
    at serveStatic (/usr/share/myapp/nodejs/node_modules/serve-static/index.js:75:16)

my guess is your flow file is larger than 5mb

The error "PayloadTooLargeError: request entity too large" occurs when the express bodyParser tries to process JSON (flow) larger than the set limit.

It is set at 5mb by default - see this line in the node-red src

Are you storing lots of base64 images in your flow? or is it just soooo large and complex?

The best solution is to see if you can tidy up your flows.

Alternatively: if you cannot reduce your flow file size, then you could increase the limit by setting apiMaxLength to something like "8mb" in your settings.js file - e.g...

    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    apiMaxLength: '8mb', ///////  <<<<<<<  uncomment & update this line

NOTE: you will need to restart node-red for it to take effect

1 Like

Yes that the probleme, I can't reduce my flow so I search the "settings.js" and I don't find it...
But thank you for confirming that my lead is the right one!
I go back to hunting for the "settings.js" file :roll_eyes:

It is in the same place as your flows file. Usually .node-red in your home folder, unless you have installed using Docker or another container. But I assume you know where your flows file is, otherwise how would you be backing it up?

If you start node-red in a terminal it will tell you where it is.

It's a bit more complicated. My Node-Red is embedded in a GSM module so it seems to me that the settings.js file does not exist.
And the stream files are saved directly on the module.
Node-Red starts from a tab on the localhost page of my module.
But I have the package.json and I found some information on this link https://nodered.org/docs/user-guide/runtime/embedding but I don't understand everything...

try creating a settings.js file in that folder.

put inside...

console.log("Hello from settings.js");
module.exports = {
    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    apiMaxLength: '6mb',
}

NOTE: I think your node-red version will need to be >= 0.20.0 - what version is on that box?

Yes I found the file settings.js in the user guide of Node-Red so I try this and I'm keeping my fingers crossed that it work :crossed_fingers:
PS : My node-red version is V1.1.0

Well... it doesn't work, I feel like I've covered everything and there are no solutions. :sleepy:

There is a sledgehammer approach...

Edit the src file and set the value explicitly.

I think I don't search at the in the right place.
What is the right path for the settings.js ?

If there isn't already a settings.js file alongside the flow files, it means your node-red instance is either:

  1. being run with the -s option to point at the settings.js file in some unknown (to us) location
  2. being run in embedded mode where some custom code on your device is providing the settings programmatically.

What is this device? Is it something you've setup yourself or is it a commercial product? Do have any access to the Node-RED log output?

My device is a Sierra Wireless FX30 3G and it is preconfigured.

Well ! I found settings.js, it was very well hidden... BUT I can't modified it because I don't have the permission... I don't understand, i'm login in admin