Uploads paths have 80 port but protocol is https

AI-generated summary

The user adopilot is experiencing issues with uploads on their Discourse instance after restoring it, as the browser shows net::ERR_SSL_PROTOCOL_ERROR due to URLs like https://forum.robot.ba:80/uploads/.... The problem arises because Discourse incorrectly appends port 80 to HTTPS URLs. jahan_gagan suggests this may be caused by a leftover port site setting in the database. To fix it, they recommend checking and clearing the SiteSetting.port value via the Rails console and then rebaking posts to update the URLs. Additionally, the user is using Let’s Encrypt, and the relevant templates are uncommented in app.yml. Guide for HTTPS with Let’s Encrypt is provided for reference.

Recently I restored my long running discource instance to new one.

My discource version are 3.6.0.beta2-latest.

Now I have problem that uploads do not works .

When I look into browser console i see lot of net::ERR_SSL_PROTOCOL_ERROR errors.

When I take look at network tab i see that chrome trying to fetch url

https://forum.robot.ba:80/uploads/default/optimized/4X/7/2/b/72be8d09005292d2f7ac37158b6d728a063f79ed_2_32x32.png

If I manually remove port 80 or change protocol from https to http and I can open link manually in new browser window.

Any idea why my discource instance adding :80 to upload paths ?

I did search site settings for force https but seems that that is not tuned on or that settings does not exist anymore.

Is is something wrong inside my app.yml file i have following templates:

(I want to use letsencrypt since i do not have my SSL cert)

templates:

“templates/postgres.template.yml”

“templates/redis.template.yml”

“templates/web.template.yml”

“templates/web.ratelimited.template.yml”

Uncomment these two lines if you wish to add Lets Encrypt (https)

“templates/web.ssl.template.yml”

“templates/web.letsencrypt.ssl.template.yml”


You can check out this guide for setting up HTTPS with Let’s Encrypt:

Possible Cause: Hidden “Port” Setting

Sometimes a hidden port site setting remains in the database after migration or restore.
This can cause Discourse to append an incorrect port (like :80) to HTTPS URLs.

To check and fix it:

  1. Enter your container:
./launcher enter app
  1. Open the Rails console:
rails c
  1. Check the current value:
SiteSetting.port
  1. If it returns 80, clear it:
SiteSetting.port = ""
  1. Then rebake all posts and assets to update links:
Jobs.enqueue(:rebake_all_posts)