Images in Uploads are inaccessible and give 404 error

I’m having an issue where uploaded images are broken, 404.

When first installed, the forum and images worked without issue. I have since migrated to s3, then back from s3 to local. The images are stored at the location that discourse is pointing to

The forum is at, is running in a docker container on port 80 and uses AWS ALB to direct the ssl traffic.

Can you suggest any troubleshooting steps that I cant take to try to find the root of this issue?


When you migrated back from S3 did you run the migrate_from_s3 rake task?

The correct URL for that image is actually:


Are your image urls omitting the local prefix?

Yes, I ran that task and rake posts:rebake. The images do appear in the directory the local directory that I would expected them to be in which is `/var/discourse/shared/standalone/uploads’.

I found that image at that location.

I’m sorry, I do not understand “Are your image urls omitting the local prefix?”

Even if you’ve got a single site install in one container your image paths should reference /uploads/default - that’s currently missing from the link your provided above, and all of the image URLs on your site.

The files aren’t broken, they’re accessible - just not where the page is looking for them. Could be a bug with the migrate_from_s3 task, @zogstrip or @tgxworld both work on the uploads.rake task and can probably comment best on this one.

1 Like

I see now. Yes, it must be a bug because I never once specified any paths to any images.

Is there a way that I can specify the root upload path manually and update it on all posts?

What is the consensus on using S3? I wanted to use S3 but read that it was not recommended so migrated back from it.

Hmm this isn’t true. Some of our hosted sites are using S3 as the upload store.

It depends on what commands you ran when you migrated the uploads to s3 and then s3 back to local. If there is a distinct pattern, you can run a remap to fix those broken paths.


Thanks @tgxworld. I followed the following steps:

  1. In the Files section of settings entered s3 credentials and a bucket name (bucket did not yet exist). and enabled s3.
  2. Ran ./launcher enter app.
  3. Ran rake uploads:migrate_to_s3
  4. Ran rake posts:rebake

Next day noticed logo and some other images were missing and I saw a (old?) forum post stating that s3 may not be ready for prime-time so performed the following steps:

  1. In the Files section of settings disabled s3.
  2. Ran ./launcher enter app.
  3. Ran rake uploads:migrate_from_s3
  4. Ran rake posts:rebake.

Now as made clear above the url of all of my images is incorrect causing the 404’s and broken images sitewide.

making a backup, restoring an older backup, then rolling back to current resolved the issue.

1 Like

I think @zogstrip might have a better idea of this here since he reworked the rake task recently.

My comment “The images are stored at the location that discourse is pointing to” was wrong as pointed out above. The location given was correct but missing /uploads/default

Restoring and rolling back the backup was only a temporary fix and broke again when I tried to enable s3. I have resolved the issue by remapping both the original and optimized directories with their proper prefixes.

1 Like

I’m unclear what broke here. Maybe you can expand more on what didn’t work? If possible, it’ll be good to provide a few upload URLs after you migrate to S3.

By broken, I’m referring to the issue described in the first messages. where the urls to images are being changed to This, of course, is wrong. url should be I did not manually make this change, something that one of the scripts did, did this.

I have since resolved the issue by using the remap command so I’m unable to show the issue now.

Before this problem started I had also changed domain name, so if you would like to try to recreate to find where the bug my process was:

clean docker install
make posts with uploaded images
change domain name per documented procedure
enable s3
migrate to s3
migrate from s3

The result of all that was that Discourse started looking for images at /original/ instead of /uploads/default/original/.