Changing Max Attachment Size


This is guide for newbies (Same as me) that clearly specify what you need to do, to allow more then 1mb for Attachment upload.

  1. Login to your SSH
  2. cd /var/discourse/
  3. nano containers/app.yml
  4. Scroll down (line 104) where it says - exec: echo “Beginning of custom commands”

Below add these yaml codes (These codes are vaildaded by )

 - replace:
        filename: etc/nginx/conf.d/discourse.conf
        from: /client_max_body_size.+$/
        to: "client_max_body_size 15m;"

Visually should look exactly like this;

Note: These settings are for 15mb. ( If you wish to increase even more,
to: “client_max_body_size 15m;” change number 15m to example; 50m )

After you done here press CTRL + O (To write that) and CTRL + X (To exit)

If you followed this tutorial from begining you should be now in /var/discourse if not, get there.

Then simply run ./launcher rebuild app

Once that complete, please navigate to

and change the max attachment size kb to 15360 (15mb) or your desired number. At this point everything should work perfectly, you can go on and test your upload file size. Cheers

Can't Increase the Max File Size
Why is Max image size limited to 100MB?
Arbitrarily large file uploads
Rebuild app fails due to allowed attachment size change
Rebuild of Discourse fails due to spaces in YAML file
With Uploads -- That page doesn’t exist or is private
(Sam Saffron) #2

there is a param for that no need to replace

This in your container template works fine:

   upload_size: 15m

Can't Increase the Max File Size
Rebuild app fails due to allowed attachment size change
Struggling to find correct instructions to increase file upload limit
How to upload videos from iphone?
Uploading video file returns "Sorry, there was an error uploading that file. Please try again."

With the param being 10m, I still can’t upload files bigger than 1m, even with “max attachment size kb” set to 10m. Did I miss anything?

(Jeff Atwood) #6

Update your discourse container to latest: ssh in, then

cd /var/discourse
git pull
./launcher rebuild app

The nginx change to make 10mb the max upload size is relatively new and part of the container.

Confirmed – it definitely works, just

  • set the upload_size: 20m under params
  • rebuilt the container
  • verified that max attachment size was 20480 in site settings

and I can now upload a 19mb attachment just fine.

(blaumeer) #14

I’m having the same issue as @snakeninny namely I’m stuck with a 1MB attachment limit.

I edited templates/web.template.yml

        upload_size: 20m


cd /var/discourse
git pull
./launcher rebuild app

As I have a ngxing reverse proxy in fron of my Discourse instance, I also edited /etc/nginx.conf

client_max_body_size 20m;

Finally, I edited the Discourse settings “max attachment size kb” accordingly.

Still it does not accenpt attachments larger than 1 MB. Any idea why?

(Rimian Perkins) #15

I changed client_max_body_size in /etc/nginx/sites-enabled/discourse and that fixed it.

I’m running the reverse proxy as per: How To Install Discourse Behind Nginx on Ubuntu 14.04 | DigitalOcean

(RBoy) #16

@codinghorror is this still required for an out of the box install or is the launcher rebuild enough to change the attachment size.

It’s a little confusing because the site admin settings mentions that client_max_body size needs to be adjusted but your post above says that just a rebuild it enough and it’ll take care of the rest.

So if I understand this correctly it’s 3 steps:

  1. Change the max attachment size kb settings in the discourse admin settings
  2. Change the client_max_body in /etc/nginx/sites-enabled/discourse
  3. Finally do a sudo ./launcher rebuild app in /var/discourse

Is that correct?

(RBoy) #17

Okay that doesn’t seem to work, there is no is /etc/nginx folder on a out of the box setup.

So is it just 2 steps then?

  1. Change the max attachment size kb settings in the discourse admin settings
  2. Do a sudo ./launcher rebuild app in /var/discourse

I believe Step 1 automatically changes upload_size in web.template.yml. If that’s the case, why not have Discourse automatically set off Step 2?

@sam @codinghorror

(Felix Freiberger) #18

No, it doesn’t. Discourse is basically sandboxed inside its Docker container and cannot “reach out” to app.yml.

(Jay Pfaffman) #19

Hey, @sam. It took me a while to track this down for a site that will be for people to share and talk about uploaded videos (they need to be protected, so youtube isn’t a convenient solution).

Is there a reason not to increase this size by default? It’d still be controlled by the SiteSetting. Similarly, would it make sense to add this to standalone.yml?

Onebox for same site not working
(Jeff Atwood) #20

I don’t see any reason why the rare video sharing site should affect this default. Discourse is not a file or video sharing solution.

(Brian Mc Gonagill) #21

Hate reviving an older thread, but I’m trying to increase upload size to 2048 m on my site, and I’ve tried all suggestions here, but nothing seems to work on a digital ocean 1-click install of discourse. Any help on how to get this upload max increased? it’s currently limited to 1024 m, even through the web.template.yml shows only 10 m. So I don’t know where this is being read from.

i tried chasing it in the app.yml, and it gave a build error on rebuild with no change. I tried the web.template.yml, and no change, and I have no /etc/nginx as it’s running in Docker.

(Eli the Bearded) #22

That’s not a supported install method, and people often find problems with that. Use the 30-minute install guide.

(Jeff Atwood) #23

I think that works OK as long as you immediately update to latest version after installing.

@techapj is the Digital Ocean one click installer still badly out of date in version?

(Arpit Jalan) #25

I just created a fresh Discourse instance using DigitalOcean’s one click installer and the version installed is 1.9.0.beta1 (last commit) … so three months behind.

(Jay Pfaffman) #26

And I’m pretty sure that last I checked it upgraded OK from the web interface (if it doesn’t run out of ram because 2GB and no swap).