Our domain name changed, where do I edit the hostname?

AI-generated summary

The discussion revolves around changing the hostname in Discourse. mholt reported that users were experiencing issues with broken links and OAuth providers due to an outdated domain name. After searching, mholt discovered that the hostname is hard-coded in the app.yml file and had to rebuild the app to change it.

codinghorror confirmed that the hostname is stored in app.yml and rebuilding is necessary to change it. jomaxro provided a guide on changing the domain name and recommended running the remap command to fix internal links and uploads. mholt questioned why links and uploads are not hostname-relative, and jomaxro explained that uploads no longer use full URLs, but links do.

After running the remap command, mholt encountered an error, which jomaxro helped resolve by adding the scheme to the URL. mholt confirmed that this solution worked.

Hi there – users are reporting that all links in emails are broken and they can’t login with any OAuth providers or reset passwords because Discourse is using a forum domain name that hasn’t been in use for about 2 years and doesn’t appear in the Discourse settings anywhere (doing a search in the admin panel for all imaginable variants of the name and terms like “domain” or “host” or “address” or “URL” yield no relevant results).

The old domain appears to be a ghost in the shell. How can I force Discourse to use the actual name we’ve been using for about 2 years?

References:

Had to log in to the server and do a global grep for the hostname on the file system and found an instance in a file called app.yml in a folder /var/discourse/containers. Apparently the hostname of the forum is hard-coded into the application instead of being configurable.

Edited the file, and it still didn’t work. Did some googling and ran /var/discourse/launcher rebuild app and after a few minutes of downtime it came back, and appears to be using the correct hostname now.

Yes, the hostname is stored in app.yml and you need to rebuild to change that.

For future reference, check out our howto at Change the domain name or rename your Discourse. After the rebuild you’ll still want to run the remap (see end of linked guide), or things (like internal links and possibly uploads depending on your configuration) will be broken.

Incidentally, that does raise a question I’ve had through this process – why are links and uploads and other site-specific assets not hostname-relative? i.e. why spell out the full URL every time?

Oh, so remapping posts is good to know (that guide you linked to didn’t appear in my googling) – but in trying it, I get this error:

Error: ERROR:  duplicate key value violates unique constraint "index_incoming_domains_on_name_and_https_and_port"
DETAIL:  Key (name, https, port)=(caddy.community, t, 443) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.

Doing what it says and re-running the script again shows the same error.

To fix that error, try adding the scheme to the url. So if your remap command was
discourse remap talk.foo.com talk.bar.com
instead try
discourse remap https://talk.foo.com https://talk.bar.com

Uploads no longer use the full URL, they’re something like ![116ae217fb1f57c4bd6058915c5db8abee9f0cd7|690x458](upload://2u570X7kQiPJQaJD1Bd8MLDHDNB.jpeg). Links do use the full domain as that’s how most people insert them into the composer, by pasting an absolute URL.

Thanks, that did the trick.