Sending email attachments "{"statusCode":413,"message":"request entity too large"}"
I'm trying to send an email with some PDF & excel spreadsheet attachments. We're self hosting Novu. Where is this error coming from? Just NGINX? How do I increase this size.
10 Replies
Hi @isaiahdahl, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* NextJS
* Push
* Firebase Cloud Messaging (FCM)
* Object Storage (S3, Blob, GCS)
-----------------------------
Answer
The error
{"statusCode":413,"message":"request entity too large"}
you're encountering generally indicates that the payload size of the request you're sending exceeds the server's limit. In the context of Novu and self-hosting, this could stem from various places, including NGINX or the Novu service configuration itself.
For Novu specifically, there has been mention of issues with large request entities, such as when sending large email content or attachments. Some users have encountered similar request entity too large
errors when working with email attachments or large template sizes (1) (2) (3) . In one instance, the issue was addressed by increasing the payload size limit in the Novu system to accommodate larger requests (3) .
When self-hosting Novu and using NGINX as a reverse proxy or gateway, NGINX can also impose limits on request sizes. You can adjust this limit by configuring the client_max_body_size
directive in your NGINX configuration file. For instance:
This example sets the maximum allowed request body size to 50 megabytes, which should be sufficient for most email attachments. Adjust the size according to your specific needs.
Remember to restart or reload NGINX after making changes to its configuration to apply them. If you're also using other services as part of your infrastructure that might limit request sizes, ensure to adjust their settings accordingly.@isaiahdahl
This size is currently fixed to 20 mb
https://github.com/novuhq/novu/blob/next/apps/api/src/bootstrap.ts#L113
I see it is not possible to customize this size.
Could you create a github issue for this? Our team will take a look for this request
!issue
Let's open an issue over GitHub! That's the link you should follow: https://github.com/novuhq/novu/issues/new/choose
I'm encountering the error with something well under 20mb. Even attempting to attach a small 80kb PDF throws the error. base64 encoded as well as not.
We have the client_max_body_size set well above 20mb
Is it possibly because the extendedBodySizeRoutes doesnlt incliude the /v1/events/trigger route?
I have the same problem. Did you found a solution? It seams that the 20mb limit doesn’t have any effect.
I've created a PR for that issue.
https://github.com/novuhq/novu/pull/6436
@Pawan Jain could please have a look into this?
@teawithfruit, you just advanced to level 1!
@isaiahdahl Could you provide us with the steps in order to reproduce the issue, if you are sending 80kb of data you should not have got this error in response.
@george.d I ended up abandoning the approach because through debugging I think I discovered the problem I was facing was that I didn't have a s3 bucket configured for the upload to upload to. At the time I couldn't find it in documentation and I didn't understand that is how attachments worked in Novu.... but when I dug through the code I could see it was trying to put my attachment in a public s3 bucket for sending, which in my case I didn't have configured.
The use case I had couldn't have the attachment uploaded to a public bucket because it was attaching some financial report PDF data so I don't use Novu for that notification.