I've tried many solutions listed here (increasing of memory limit, adding parameterlimit, adding type as 'application/json') to fix this 'Request Entity too large' error (it also returns http code 413). But none of them seem to make this error go away.
The current size of the json can range from 200k up to 400k entities.
Here is the current configuration:
app.use( bodyParser.json({limit: "15360mb", type:'application/json'}) );
app.use(bodyParser.urlencoded({
limit: "15360mb",
extended: true,
parameterLimit:5000000,
type:'application/json'
}));
app.use(bodyParser())
Any ideas on how to increase the limit?
More information
This is the full error message if it helps:
{ Error: Request Entity Too Large
at respond (/home/nodejs/server/node_modules/elasticsearch/src/lib/transport.js:307:15)
at checkRespForFailure (/home/nodejs/server/node_modules/elasticsearch/src/lib/transport.js:266:7)
at HttpConnector.<anonymous> (/home/nodejs/server/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
at IncomingMessage.bound (/home/nodejs/server/node_modules/lodash/dist/lodash.js:729:21)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
status: 413,
displayName: 'RequestEntityTooLarge',
message: 'Request Entity Too Large',
path: '/_bulk',
query: {},
body: '<large body here>'
}
Solution
The error was indeed due to wrong configuration on elasticsearch and not nodejs. Manage to fix this by following https://github.com/elastic/elasticsearch-js/issues/241 and setting http.max_content_length: 500mb
in elasticsearch.yml
.
@ryanlutgen also provided a link for more information about this error here. https://github.com/elastic/elasticsearch/issues/2902
This issue has been fixed. Thanks for all the input!
If You doesn't solve your issue, bodyParser also has a limit. You must use
app.use(bodyParser({limit: '4MB'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With