Change the maximum attachment/upload size

:bookmark: This guide explains how to change the maximum attachment upload size for self-hosted Discourse instances.

:person_raising_hand: Required user level: System Admin

The default attachment upload size limit is 10MB

If you are self-hosting Discourse and need to allow uploads larger than 10 MB, follow the steps below.

Changing the upload size

  1. Connect to your server:
  • Use SSH to access your server’s command line interface.
  1. Edit the configuration file:
  • Navigate to the configuration directory and edit the app.yml file:
cd /var/discourse/
nano containers/app.yml
  1. Modify the upload parameters:
  • Look for the section labeled params. Directly below, add your desired upload size with careful attention to formatting:
params:
  ## Which Git revision should this container use? (default: latest)
  version: latest
  ## Maximum upload size (default: 10m)
  upload_size: 20m
  1. Save your changes:
  • Press Ctrl+X to exit, then Y to confirm, and Enter to save the changes.
  1. Rebuild the Discourse instance:
  • Run the following command from the /var/discourse directory:
./launcher rebuild app
  1. Update site settings:
  • Go to /admin/site_settings/category/files in your Discourse dashboard.
  • Adjust the max attachment size kb to 20480 (for 20 MB) or your preferred size.
62 likes
Can't Increase the Max File Size
What is the max image upload size limit by file type
Image upload size/resize question
Struggling to find correct instructions to increase file upload limit
Upload Large Video
Can't Increase the Max File Size
What is the maximum file size we can upload on discourse?
:cn: Change the max size of uploads/attachments | Discourse 修改上传附件的大小
Image upload error when using resizer
With Uploads -- That page doesn’t exist or is private
Rebuild of Discourse fails due to spaces in YAML file
Category image upload stops at 0%
Issue with maximum upload file size
Attachments max size limit in self and business hosting difference
Do I need to install NGINX and PHP to optimize my Discourse forum?
Remove Dropbox Onebox For Audio Links
Uploads involving client-side JS preprocessing fail in Chrome based browsers
“Image larger than 4mb” error when posting a gif
Inquiry About Discourse’s Support for Amazon S3 Storage
Increasing max file size
NGinx.conf File location
Multipart upload
Can Discourse accept attachments when using emails to create new category topics?
What is the maximum file size we can upload on discourse?
Problem about attachment file size
Max upload size error
Why is my upload limit 100mb?It's set to 500mb
Issue with maximum upload file size
Meta Data From Image Upload
How to change upload limit by command line
Attachments: Oops! That page doesn’t exist or is private
Increase the file size of attachment
Sorry, that file is too big V2
Raising max file upload limit in configs
Allow log file for topic and restricted to admin

Why is the error message incorrect though? Here is my error message.

While trying to upload a 10mb file. The error message is incorrect.

3 likes

What kind of file was it? Are you able to upload other files to that site?

Sometimes there are browser issues during the upload process that cause temporary issues. Please try uploading your file again, in a new browser session.

2 likes

Has this article not been updated for a long time? Why can’t I find “upload_size: 20m”???

2 likes

The first post was updated 5 days ago

The guide says you need to add that line. So, before adding it, you won’t find it. I added some formatting in the quote below. Does that help you?

9 likes

does it also affect the max image size kb setting?

1 like

Yes, it does affect any type of upload.

More specifically, I believe the upload_size app.yml setting is given to nginx as client_max_body_size, which is the same parameter provided in the two site settings descriptions:

Max image size KB The maximum image upload size. This must be configured in nginx (client_max_body_size) / apache or proxy as well. Images larger than this and smaller than client_max_body_size will be resized to fit on upload.
Max attachment size KB The maximum attachment files upload size. This must be configured in nginx (client_max_body_size) / apache or proxy as well.
4 likes

This setting now allows the inputting of MB directly:

Perhaps the setting needs a rename, and the text above updated?

Unless something has changed, what this change to the yml does is change what the maximum size that Discourse allows is. That is, the max size available in the ux is 10mb. This lets you increase that maximum by changing some stuff in the nginx config files.

What I meant was that you no longer need to input kb in the site setting - not that the functionality had changed.

Although it would be nice if the site setting simply reflected what was in the YML without the need for a separate setting.

1 like

I think while the user input allows using MB too, the value is always saved in KB.

To me, setting names aren’t information for the user but more of a technical term to identify the setting. They aren’t translatable, so admins using Discourse in a different language won’t necessarily understand them at all. And configuring Discourse should work for them too. So the description needs to be good enough on its own.
Maybe English-speaking users should use that perspective too and ignore the setting name, focusing more on the description. Then you wouldn’t be confused by the name.

1 like

But you might, say, have a multisite instance and some sites want less than the theoretical maximum. That’s at least part of why there are two settings.

1 like

How about we improve the description text for that setting, and link to this Topic in it?

I think that would make things better for everyone.

1 like