Change the domain name or rename my Discourse?

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

talk.foo.comtalk.bar.com

Let’s get started.

Set the TTL for your DNS low, and in advance

You need to let everyone know that the domain is about to change, so change the TTL for your domain name to something low, like 60 minutes.

Do this days in advance so the change can propagate throughout the Internet, and the domain name change will take effect quickly.

Remove old domain name from any site settings

Visit /admin/site_settings and query for any settings that contain the old site name.

If you get any hits on the old domain name, make sure you change those values.

Edit Discourse site name in app.yml

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

Edit the hostname line in app.yml

## The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: 'talk.bar.com'

(Also, if you are using a CDN, turn it off now by commenting out that line in the app.yml. You can turn it back on later.)

After the change, rebuild:

./launcher rebuild app

Once you do this, your site will only respond to the new domain name.

Change Your DNS

  • turn off the old domain name

  • point your new domain name to the IP of your Discourse.

Everything should come up OK, provided the site name was changed and the instance rebuilt properly in the previous steps.

Verify that the site is up and functioning, but to do that you probably need to log in, right? Which brings us to…

Fix 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.

Your Twitter, Facebook, Google, Yahoo, GitHub social logins will all need to be edited to reflect the new domain name too. Refer to the respective guides in the howto category here.

Replace all instances of the old name with the new name in posts

All the existing posts will still refer to the old domain. Let’s fix that:

./launcher enter app
discourse remap talk.foo.com talk.bar.com
rake posts:rebake

This remaps text in posts from the old URL to the new URL, then regenerates all posts just in case.

And now you’re done!

(but don’t forget to turn the CDN back on after this, if you had one.)

111 Likes
Move your Discourse Instance to a Different Server
Changing the subdomain
Assets broken after moving installation to subdomain
Changed Domains- Not getting redirects
Transfer Discourse forum to another domain
Great How To Guides
Unable to change email address after switching domains
Having an issue after changing domain
Put forum under sub-domain and have website
Broken image URL paths after changing hostname
Nil usage errors in un-self-deleting posts
Effect of changing the WordPress site URL
Restore backup without reconfiguring Discourse
Switching forum from subdomain to sub directory
Creating a duplicate of production environment
Rename custom domain of hosted Discourse forum
Discourse none admin side not working returning error 500
File URLs broken after moving to a different domain
How can I bulk remap/update user email addresses?
How can I bulk remap/update user email addresses?
Authentication and changing domain
Changed Forum Address. Activation Still Links to Old Address
Redirect discourse URL
How to change the domain for Discourse?
Our domain name changed, where do I edit the hostname?
Hosted-by-discourse.com .. how to configure / rebake / ssh?
To move site to a different domain name
Re-Run Setup Discourse
Preparing test Installation -some questions
Preview links help
Changing site URL
How to change domain but without lost ranking
Moving to subdomain
Domain change and hyperlinks
WP Discourse - Relinking Comments After Moving Blog
Image links point to Incorrect (Previous) subdomain After Migration
Assets broken after moving installation to subdomain
Migrating from SMF to Discourse
After SSL installation pictures are not displayed
Bootstrap failed after rebuild - changed domain name

Hi @codinghorror, Thanks! I’m going to move http://forum.railsonmaui.com to forum.shakacode.com (to complement our open source at ShakaCode · GitHub).

  1. Any tips on how to maintain good SEO that was going to the old domain name?
  2. Can I keep the old blog and the new blog linked to the same forum, @eviltrout? I could also move all the old blog content over to the new domain, and keep the only articles there, changing the "rel=“canonical” to the new domain.

railsonmaui.com had to switch, as we’re probably going to open an offices Oahu, Kauai, and Bali eventually, and we do way more than Rails. We’re excited about the new name! And it’s a big WE now, with team members in Russia, Cambodia, Brazil, San Francisco, Toronto, Minneapolis, and, of course, Maui.

1 Like

Google’s pretty good about following redirects. Just set up a redirect (in addition to everything here) and you should be good.

@codinghorror Jeff, do you mean being able to login with social accounts? I don’t have that setup … I guess that’s now on my todo list.

Yikes, should this be more towards the top, or bolded?

More explicitly, I think that would include the initial DNS steps you sent via email.

Some DNS changes are needed at your domain talk.bar.com

  1. Set the A record of forum to 104.XXX.XXX.XXX (your server address):

  2. To enable mail delivery DKIM, create a TXT record for mandrill._domainkey with the following value:

     v=DKIM1; k=rsa; p=MIGfMA0...LONG_KEY_HERE..;
    
  3. To enable mail delivery SPF, create a TXT record for talk.bar.com with the following value:

     v=spf1 include:spf.mandrillapp.com ?all

Do you have a pro tips for people using https with Let’s Encrypt ?
I’m actually following this howto to change my domain name and I now have to remove my old certificat to add a new one.

2 Likes

Do we have to change mailgun configuration (or mail server equivalent configuration)? Or can we stay with old configuration (with old domain)?

Mailgun will be OK if you keep sending from the old domain name. You might need to tweak this (near the end of app.yml when you make the change:

  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
2 Likes

Hey,

I have a question, I changed the CDN service provider, url a.a.com to b.b.com, but now all post image is a.a.com canot display.

You’ll need to remap all your old baked posts to refer to the new CDN provider. There are existing topics on how to do this.

I have use rake posts:rebake

but now all images not use CDN url, just use my forum URL.

how can I fix this.

// update: OK, now I have launcher rebuild app, fix this.

1 Like

Both discourse.mydomain.com & www.mydomain.com are point to same IP address.

Followed the instruction to change from discourse.mydomain.com to www.mydomain.com. And no error after./launcher rebuild app

But looks like nothing changed. I can only access to the old domain name discourse.mydomain.com

Is there anything else I can do?

It is incorrect for two different domain names to resolve to the same content, this will lead to huge duplicate content penalties in Google.

However you can redirect one domain name to the other. That is a completely different topic and is off-topic in this one.

1 Like

9 posts were split to a new topic: Do I need to rebuild when my domain name changes?

I wanted to know what is the procedure for dual container install with separate container for Data and Web.

My installation is on dual container.

Edit the web container’s .yml for DISCOURSE_HOSTNAME and rebuild that container. Everything else is the same.

4 Likes

8 posts were split to a new topic: Issues with base_url after renaming forum

I want to change my subdomain for my Discourse installation like sub1.site.com to sub2.site.com

I changed hostname in app.yml. After change, rebuild app. Now, Discourse is live again but nothing is changed. Discourse still works on sub1.site.com domain.

Where can the problem be?

I notice @bekircem asked a question that has not seen an answer, and as a basic user, I will be facing the same challenges he faced. Do we have a solution? I want to change subdomains on the same domain.

It’s unclear whether there is (or was) a bug or if he did something wrong. @bekircem, did you did your problem? Do you have a standard install or do you have something upstream that’s doing a reverse proxy that needs to be changed?

I am yet to start my switch, so I was reading on what’s closest to mine, and I found this one that wasn’t addressed. The tutorial at the beginning of this thread is for advanced users. Makes so many assumptions.