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

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:

1 Like

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.

6 Likes

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

3 Likes

For future reference, check out our #howto at Change the domain name or rename my 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.

2 Likes

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.

4 Likes

Thanks, that did the trick.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.