# Rake uploads:migrate\_to\_s3 fails because DISCOURSE\_S3\_CDN\_URL env var is empty

**URL:** https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624
**Category:** Self-hosting
**Created:** [September 27, 2019, 12:39am UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624 "2019-09-27T00:39:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chetan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chetan/32/141503_2.png) [@chetan](https://meta.discourse.org/u/chetan)
#### Post date: [September 27, 2019, 12:39am UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624/1 "2019-09-27T00:39:24Z")

</div>

rake uploads:migrate\_to\_s3 fails because DISCOURSE\_S3\_CDN\_URL environment variable is empty

How to tackle this?

I’m not using CDN - so I’m not sure what to put there.

Please help.

---

<div class="post-metadata">

### Author: ![eatcodetravel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eatcodetravel/32/94385_2.png) [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)
#### Post date: [September 27, 2019, 1:32am UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624/2 "2019-09-27T01:32:43Z")

</div>

I think there’s an issue with how Discourse handles this. When you move uploads to S3 and set the `DISCOURSE_S3_CDN_URL` env variable, Discourse tries to fetch assets from S3 too. I had to move uploads and assets to S3 + Cloudfront to make it work, but it shouldn’t be needed since you only want uploads to be on S3

You can check this thread to see if it helps.

> [@Defining DISCOURSE\_S3\_CDN\_URL links to assets in S3 CDN URL](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798):
>
> I had this problem before and decided that I was crazy, confused, or the database on the site was suspect, but this is on a brand new site. Also, I was on Digital Ocean spaces, so I thought it might be a problem somehow. I’m trying again to figure out how to keep images on AWS S3 like I think the Big Boys do. Here’s what I have in the env section: DISCOURSE\_S3\_ACCESS\_KEY\_ID: 'key' DISCOURSE\_S3\_SECRET\_ACCESS\_KEY: 'lock' DISCOURSE\_BACKUP\_LOCATION: 's3' DISCOURSE\_S3\_BUCKET: 'lc-xyz' DI…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 16, 2023, 4:19am UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624/3 "2023-05-16T04:19:10Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [May 16, 2023, 8:51am UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624/4 "2023-05-16T08:51:25Z")

</div>


