Change the domain name or rename your Discourse

:bookmark: This guide explains how-to change the domain name of your Discourse site, and includes information about setting up DNS changes, editing configuration files, updating site settings, and correcting social logins and post content to reflect your new domain name.

:warning: This guide is for self-hosted Discourse instances that were installed using our installation guide on GitHub. If you are hosted by Discourse, please see Configure your domain name for hosted Discourse for specific instructions.

You may eventually want to change the domain name of your Discourse instance, from say

=BEFORE==AFTER=

Let’s get started.

Setting the DNS TTL low in advance

First, change the Time-To-Live (TTL) setting for your DNS to a low value like 60 minutes. This should be done days ahead of the actual domain change to ensure the change can propagate quickly across the internet.

Remove old domain name from any site settings

Visit /admin/site_settings in your Discourse admin interface, and search for any settings containing the old domain name. Update these settings to the new domain name.

Changing DNS Records

Update your DNS settings to disable the old domain and point the new domain to the IP address of your Discourse server.

Editing the site name in app.yml

You can edit the app.yml file manually to input the new domain information.

Here’s how to edit it manually:

cd /var/discourse
nano containers/app.yml

Locate the following line and replace it:

DISCOURSE_HOSTNAME: 'your.newdomain.com'

If using a Content Delivery Network (CDN), temporarily disable it by commenting out the respective line in app.yml. Rebuild your Discourse site with:

./launcher rebuild app

:information_source: Alternatively, you can run ./discourse-setup again and input the new domain information instead of editing app.yml.

Check that your site is operational under the new domain.

Fixing social logins

:exclamation: Depending on how you logged in, you may need to do this first or you won’t be able to log in once the name is changed.

If you use social logins, update the credentials on the platforms (Twitter, Facebook, Google, Yahoo, GitHub) to reflect the new domain. Look for guides on the Discourse how-to category.

Remapping domain names in posts

All the existing posts will still refer to the old domain.

You’ll need to change old domain references in your posts to the new domain:

./launcher enter app

then

discourse remap =BEFORE= =AFTER=

Alternatively, use Rake if discourse binary is unavailable, you can use the rake version:

bundle exec rake posts:remap["=BEFORE=", "=AFTER="]

Finalize with:

rake posts:rebake

This ensures that the domain name remaps in existing posts, and content is regenerated as necessary.

:information_source: If you have a CDN, remember to reactivate it post-domain change.

wondering how we created that form?

Last edited by @SaraDev 2024-12-13T00:50:25Z

Check documentPerform check on document:
189 Likes

There is really no reason for a rebake?
The remap already took care of mapping the old URL to the new URL.

4 Likes

@SaraDev Thanks for keeping things tidy. Can you have a look at:

and

Maybe I am missing something but… If you use the ./discourse-setup method you will need to set the ip for the new domain prior to running ./discourse-setup to prevent the dreaded domain check failure, yikes.

Using the talk.foo.comtalk.bar.com convention

Hostname for your Discourse? [talk.foo.com]: talk.bar.com

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname: talk.bar.com.
WARNING: Connection to http://talk.bar.com (port 80) also fails.

2 Likes

Hi @philh,

Thanks for mentioning this:

This is correct, and if you run ./discourse-setup to and input the new domain information instead of editing app.yml you will need to setup the DNS records for your new domain first.

This information has updated this in the guide to reflect the correct order for updating the domain in this situation. :slightly_smiling_face:

1 Like

Thanks Sara!

BTW: I am pretty sure there is a domain check during rebuild running ./launcher rebuild app :wink: which would suggest dns should be updated 1st either way: direct edit of app.yml or ./discourse-setup

Thanks again for working to keep things tidy. Up to date instructions does help the newer folks that come along. :slight_smile:

2 Likes

I want to do this, but I’m using Digital Ocean, and I’m no expert. Is there anything I need to change there?

For example I see this:

But I believe this is just a name I gave it, it’s not a real setting?

So as long as I follow the instructions on this page, I don’t have to make any changes in Digital Ocean (maybe apart from updating this name to the new domain, to avoid confusion?)

To make your new site work properly, you need to update the DNS settings at your domain name provider.


Example:

If your previous site was:

forum.example.com → 1.1.1.1

Then you should change it to:

forum.newname.com → 1.1.1.1


Are you changing the subdomain or the full domain?

In the example above:

  • Domain: example.com
  • Subdomain: forum

Make sure to update your DNS records accordingly depending on whether you’re changing only the subdomain or the full domain name.



:label: Are you changing the subdomain or the full domain?

In the example above:

  • Domain: example.com
  • Subdomain: forum

Make sure to update your DNS records accordingly depending on whether you’re changing only the subdomain or the full domain name.


:globe_with_meridians: DNS Configuration Examples

:blue_circle: Cloudflare

  1. Log in to your Cloudflare dashboard.
  2. Select your domain (e.g., example.com).
  3. Go to the DNS tab.
  4. Find the existing A or CNAME record for forum.
  5. Edit it:
    • Name: forum
    • Content: 1.1.1.1 (or your server’s IP)
  6. Click Save.

:yellow_circle: GoDaddy

  1. Log in to your GoDaddy account.
  2. Click on Domains, then select your domain.
  3. Under Additional Settings, click Manage DNS.
  4. Scroll to the Records section.
  5. Find the A record or CNAME for forum, and click the Edit icon.
  6. Update the following:
    • Host: forum
    • Points to: 1.1.1.1
  7. Click Save.

:orange_circle: Namecheap

  1. Log in to your Namecheap account.
  2. Go to Domain List > click Manage next to your domain.
  3. Open the Advanced DNS tab.
  4. Under Host Records, look for the entry with forum.
  5. Click Edit, and update:
    • Host: forum
    • Value: 1.1.1.1
  6. Click the green checkmark to save the change.

DNS changes may take from a few minutes up to 48 hours to fully propagate, depending on your provider and TTL settings.

:three_o_clock: Note: The steps for changing DNS were generated using AI, and they may vary or contain errors.

1 Like

My issue was actually just related to Digital Ocean, not the DNS, which I was able to change easily in Cloudflare. I figured out it was not necessary to make any changes in Digital Ocean, though.

Thank you for your reply, anyway!

1 Like