Changing Max Attachment Size

Here is what you need to do to allow more than 10mb for attachments upload.

  1. Connect to your server via SSH

  2. cd /var/discourse/

  3. nano containers/app.yml

  4. Scroll down where it says db_default_text_search_config under params

Add upload_size: 20m below db_default_text_search_config

  db_default_text_search_config: "pg_catalog.english"

  # replace 20m with desired value
  upload_size: 20m

After making changes press Ctrl+O (to write) and Ctrl+X (to exit).

From /var/discourse run:

./launcher rebuild app

Once rebuild is complete, navigate to and change the max attachment size kb to 20480 (20mb) or your desired number. At this point everything should work perfectly, you can go on and test your upload file size.



I’ve followed these instructions but when I send an email to my category with an attachment with around 9mb, I get:

Message too large

Your message couldn’t be delivered to [] because it exceeds the size limit. Try reducing the message size and resending.
The response from the remote server was:

552 5.3.4 Message size exceeds fixed limit

P.S. [] is a “category” email

This is completely unrelated to Discourse, that error is coming from your mail server. The mail server is not even handing the mail over to Discourse it is rejecting it.


Thanks for pointing this out Sam. From your answer I went on and took another look and managed to someway fix this issue.
I started by questioning if this was on sender or receiver side. Sender was gmail and the limit was 25 mb so it couldn’t be there. Receiver was mail_receiver.
Below a link where I also share what I’ve done in case someone faces a similar issue.

I’ve done this but can’t make it work

I checked after rebuild that in the container the nginx conf file correctly has the client_max_body_size 200m ;

Since I have a multi-site server configuration as shown in Running other websites on the same machine as Discourse I also added the line client_max_body_size 200m ; in the outer nginx conf and restart

but I still have max_attachment_size_kb: Value must be between 0 and 1024000.

any other setting to change ?

1 Like

Should this still work? I changed upload_size: 25m, rebuilt, confirmed that it was set in /etc/nginx/conf.d/discourse.conf, but when I try to change the max attachment size kb I still get max_attachment_size_kb: Value must be between 0 and 1024000. This is a subfolder install behind an Apache reverse proxy (seemed like a good idea at the time), but max there is 200MB).

There is lots of discussion like Upload_size in app.yml not working and Error with very large file uploading, but those are different problems (mostly unicorn or other components crapping out because they can’t handle it).

Rails says:

Discourse::InvalidParameters: max_attachment_size_kb: Value must be between 0 and 1024000.
from /var/www/discourse/lib/site_settings/type_supervisor.rb:215:in `validate_value'

I poked around but can’t quite tell how it’s determined what the max max attachment size can be.