# Error with very large file uploading

**URL:** https://meta.discourse.org/t/error-with-very-large-file-uploading/80326
**Category:** Bug
**Created:** [February 11, 2018, 8:17pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326 "2018-02-11T20:17:35Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 11, 2018, 8:17pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/1 "2018-02-11T20:17:35Z")

</div>

Hi! 🙂

We are testing Discourse to use as a forum application for our community, and so far it looks quite great.

In addition to normal forum functionality, we have some specific needs.

From time to time we need to upload files to the forum, these are about 10MB-200MB in size (audio recordings).

Unfortunately we are now experiencing some difficulties with the file uploading. If the file is about 50MB or less it seems to upload fine, but something like 80MB and larger gives _"Sorry, there was an error uploading that file. Please try again.”_ error to the screen.

Our Discourse version is v2.0.0.beta2 +115

We have added the parameter `upload_size: 150m` into `app.yml` (and ran ”`./launcher rebuild app`”), and changed the ”max attachment size kb” from /admin settings to ”150000”.

i can’t see anything error related in production.log and there is nothing in production\_errors.log, but `nginx/error.log` shows this:

> `2018/02/11 16:53:35 [error] 70#70: *8891 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xx.xx.xx.xx, server: _, request: “POST /uploads.json?client_id=b4952f07d4d949e4a87c176473fbb5d6&amp;authenticity_token=e%2F%2FRKI3YDCVCixp76YaIqpLTib6zdrO0vZBAYlHPVcZVBJUx%2BEy2juQ5xMrTeUPZoyX0uJzTPW7pCey47YRvwQ%3D%3D HTTP/1.1”, upstream: “http://127.0.0.1:3000/uploads.json?client_id=b4952f07d4d949e4a87c176473fbb5d6&amp;authenticity_token=e%2F%2FRKI3YDCVCixp76YaIqpLTib6zdrO0vZBAYlHPVcZVBJUx%2BEy2juQ5xMrTeUPZoyX0uJzTPW7pCey47YRvwQ%3D%3D”, host: “server”, referrer: “http://server/c/test-category”`

Around the same time as the upload fails, the file `unicorn.stderr` gives this error:

> `E, [2018-02-11T16:53:35.331265 #73] ERROR -- : worker=0 PID:6403 timeout (31s > 30s), killing`

Could there be a some kind of timeout/limit issue somewhere?

i’ve been trying to find a solution to this, but it seems i can’t get anywhere.

Our test server is a VPS with 1GB of memory (and a 3GB swap file).

We would not want to give up on Discourse just yet, so any help is truly appreciated! 😀

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 12, 2018, 2:44am UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/2 "2018-02-12T02:44:10Z")

</div>

There is a topic that describes how to modify the nginx container to show larger uploads. I did it once for a group that wanted to discuss videos.

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 12, 2018, 8:21pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/3 "2018-02-12T20:21:46Z")

</div>

> [@pfaffman](#):
>
> There is a topic that describes how to modify the nginx container to show larger uploads. I did it once for a group that wanted to discuss videos.

Thank you for the reply 🙂  
Do you mean there is something else that needs to be modified too? In addition to changing the upload limit on admin panel and changing `client_max_body_size` in `nginx.conf` (nginx.conf was modified by adding `upload_size` parameter to `app.yml`)?

I have been trying to look for this topic you mentioned, but all i can find are references to these modifications above, which we have already done. Perhaps i’m missing something here?

Thanks in advance for all the help!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 12, 2018, 8:29pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/4 "2018-02-12T20:29:29Z")

</div>

Oops. I missed that you’d changed the upload size in `app.yml.` That’s what I was talking about. Sorry.

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 13, 2018, 4:57pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/5 "2018-02-13T16:57:38Z")

</div>

> [@pfaffman](#):
>
> Oops. I missed that you’d changed the upload size in app.yml. That’s what I was talking about. Sorry.

You are forgiven 😁

So, we are still stuck with this. Is there anything else we could check in order to figure this out? Some additional log files? Perhaps a way to increase debug level and see what’s going on in detail?

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 13, 2018, 5:18pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/6 "2018-02-13T17:18:25Z")

</div>

As a side note, the server is running quite low on memory and the output of `free -m` often looks something like this:

> ```
> total used free shared buff/cache available
> Mem: 992 735 86 22 170 83
> Swap: 3068 496 2572
> 
> ```

Could this perhaps be a performance issue due to lack of memory?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 13, 2018, 5:27pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/7 "2018-02-13T17:27:47Z")

</div>

> [@Liviyahu](#):
>
> Could this perhaps be a performance issue due to lack of memory?

Yes. Does `free -h` show 1GB? `./discourse-setup` won’t install if it sees less than 1GB of RAM. I’m not sure how and whether `free` rounds, though. Is this a [standard install](https://meta.discourse.org/t/142537?silent=true)?

Where are you hosted? But increasing RAM is definitely a good idea. If you’ve got a 150GB upload, that’s a pretty substantial part of your available RAM.

I’d bump to at least 2GB of RAM to see if that solves your problem.

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 13, 2018, 5:45pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/8 "2018-02-13T17:45:19Z")

</div>

> [@pfaffman](#):
>
> Yes. Does free -h show 1GB? ./discourse-setup won’t install if it sees less than 1GB of RAM. I’m not sure how and whether free rounds, though. Is this a [standard install](https://meta.discourse.org/t/142537?silent=true)?

Yes, this is just a test server (VPS at [Transip](https://www.transip.eu/)) to see if Discourse suits our needs. So it has minimum requirements (1GB RAM). We have not yet decided our final hosting provider.

We followed the installation instructions described [here](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md). So it should be pretty standard.

> [@pfaffman](#):
>
> If you’ve got a 150GB upload, that’s a pretty substantial part of your available RAM.

To clarify: the upload is 150MB, **not** 150GB.

From the original post:

> [@Liviyahu](#):
>
> From time to time we need to upload files to the forum, these are about 10 **MB** -200 **MB** in size (audio recordings).

So it’s megabytes, not gigabytes 🙂

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 13, 2018, 9:23pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/9 "2018-02-13T21:23:39Z")

</div>

Yeah. I mean MB, but 150MB is a sizable part of 1GB.

Is the error you’re getting “`Sorry, there was an error uploading that file. Please try again.`?”

I confirm that I just did a new install and upped the RAM to 4GB (and rebuilt after adjusting the memory settings). Upoading a 40MB file works fine, but an 83MB file gets that error.

Seems like this might be a bug.

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 13, 2018, 10:11pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/10 "2018-02-13T22:11:06Z")

</div>

> [@pfaffman](#):
>
> Is the error you’re getting “Sorry, there was an error uploading that file. Please try again.?”

Yes, exactly that.  
Along with the log file findings shown in the first post 🙂

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 13, 2018, 11:00pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/11 "2018-02-13T23:00:55Z")

</div>

If we can repro a bug here is there anything we can do to address it @zogstrip?

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 22, 2018, 10:25am UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/12 "2018-02-22T10:25:09Z")

</div>

Hi again 🙂  
Are there any news regarding this issue?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 22, 2018, 10:32am UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/14 "2018-02-22T10:32:31Z")

</div>

Sorry hadn’t had a chance to look at it yet. Added to my list.

---

<div class="post-metadata">

### Author: ![Liviyahu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/liviyahu/32/90807_2.png) [@Liviyahu](https://meta.discourse.org/u/Liviyahu)
#### Post date: [February 22, 2018, 12:45pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/15 "2018-02-22T12:45:49Z")

</div>

> [@zogstrip](#):
>
> Sorry hadn’t had a chance to look at it yet. Added to my list.

Okay - thank you!  
Let us know how it goes 🙂

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [August 20, 2018, 3:07pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/16 "2018-08-20T15:07:53Z")

</div>

I’m not sure there’s much to do here 😕

If uploading a file monopolizes a unicorn worker for more than 30 seconds, then you should use a proper file hosting service instead? There’s a good reason we have a “short” timeout 😉 (_hint DoS_)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 25, 2018, 11:47pm UTC](https://meta.discourse.org/t/error-with-very-large-file-uploading/80326/17 "2018-08-25T23:47:36Z")

</div>


