Changing Max Attachment Size

:mega: If you are on managed hosting, you should contact your hosting provider to change this setting. The below instructions only apply if you self host your own instance of Discourse.

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.



Hey @JammyDodger . Check this out. I’m pretty sure that to do this you also need to do something like

cd /var/discourse
./launcher enter app
apt-get update
apt-get install -y nano
cd /var/www/discourse
nano config/site_settings.yml
<find max_attachment_site_kb and make it a bigger number>
sv restart unicorn

then in the UX you can change that value to something bigger. That change that allows a bigger number to get entered will be erased on the next rebuild, but I’m pretty sure that won’t matter as long as you don’t try to change it again.

I actually changed the value using rails c and entering the value that way, but the UX is likely more intuitive for most people (and people who would rather change it with Rails won’t need to be told how to do it).

If you do the above and do a rebuild and it still works, then we can edit the instructions to include making the change that makes it possible to increase the max_attachment_size_kb or maybe ask Sam if he thinks there is or should be some less hacky way to do it.

1 Like

But that doesn’t apply when there is another Nginx/what-ever sitting front of docker, right?

Yes. It all applies and then you also need to do the same for the external nginx.

Really :flushed:

I’ve done that but only on the external Nginx. I never touched docker (because I don’t know how and can’t but that is another story; your guide was spot on). But I changed limits — or did I just imagine that change, because that is an option too.

We’re you able to upload files bigger than 10mb? Without making the changes described in the OP?

Yes. I just tried 50.9MB video clip and it uploaded just nicely. And yes, without those changes.

S3 doesn’t play in roll here?


Because I don’t trust on me too much I checked out app.yml. There was upload_size: 250 m so I have changed things on side of Discourse. But never something you adviced. But I changed setup of ”front Nginx” bacause app.ym alone didn’t work.

Am I mixing things, again?

Responding from mobile, excuse brevity.

Jay, I only added upload_size: 500m to app.yml, then set the max attachment size kb to 51200.

Rebuilt, uploaded ~150MB WebM video, which uploaded in the browser fine, and uploaded to object storage, embedded with CDN link, everything’s :+1:.

Standard install (but on Linodes vps and buckets).

1 Like