Change the domain name or rename your Discourse

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

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

From the root directory where you installed Discourse you can run the follow to edit your app.yml file

cd /var/discourse
nano containers/app.yml

Then find and edit:

## The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: '=AFTER='

(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

then

discourse remap =BEFORE= =AFTER=

answer its paranoia prompt, and finally

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

wondering how we created that form?


Last Reviewed by @AlexDev on 2022-05-24T21:00:00Z

165 Likes
Changing the subdomain
Move your Discourse Instance to a Different Server
Changed Domains- Not getting redirects
Having an issue after changing domain
Great How To Guides
Put forum under sub-domain and have website
Our domain name changed, where do I edit the hostname?
Got a strange error when I transferred our forum to the new server and new domain
Image links point to Incorrect (Previous) subdomain After Migration
WP Discourse - Relinking Comments After Moving Blog
Unable to change email address after switching domains
Moving to subdomain
Unable to change domain name
Links broken after move
How can I bulk remap/update user email addresses?
Rebake fails when changing the subdomain name only
Rename existing discourse site
I have a few questions before migrate from Xenforo 2.x to Discourse
Moving from one S3 bucket to another
Preparing test Installation -some questions
Re-Run Setup Discourse
How to change the domain for Discourse?
Can I change the domain name - without a clean install?
Links broken after move
Moving from Vultr to DigtitalOcean
Migrate a phpBB3 forum to Discourse
Missing avatars and site images after import of a backup
Discourse Install on Lightsail
Changing domain from command line
Ssl_error_bad_cert_domain
Avatars lost after restore. How to get them back?
Got a strange error when I transferred our forum to the new server and new domain
How to change URL associated with Activate Account button
Avatars lost after restore. How to get them back?
How might we better structure #howto?
Problem accessing plugin admin after restore
Migrate from AWS to Digital Ocean with 2 containers, spaces and 2 CDNs
Problem linking Discourse forum to WP Discourse
Site responds 502 Bad gateway - is it Ruby?
All internal links broken after restoring backup to new server
Image uploads used to work but no longer do after forum name change?
Administrative Bulk Operations
Lost DNS Name, need to change to a new one
Questions about rebake
Cloned my DO discourse droplet, how to get clone to go to right domain?
Too many user emails domains not working lead to mailgun domain disabled: what to do?
I got example.com links. Where do they come from?
Problem linking Discourse forum to WP Discourse
Help changing domain
Onebox error code of 403
Move Discourse to a new server without setting up the web UI first?
如何修改 Discourse 的域名
Can not save Default Watched Category/Tags
Using external Domain in the browser address line
After activating HTTPS Discourse doesn´t work
504 Gateway error after launching new AWS instance
Adding www. to Domain
Unable to rebuild discourse due to no space left on device
Jump to main address automaticly?
Changed domain of WordPress and Onebox
Can't reach site
Can't Reach Site (Take 2)
Admin panel messed up after changing the domain name
What I should know when changing the domain name of a discourse forum
How to change URL associated with Activate Account button
Any ideas why my discourse can't show emoji and images?
Migrating from SMF to Discourse
After SSL installation pictures are not displayed
Bootstrap failed after rebuild - changed domain name
Authentication and changing domain
Nil usage errors in un-self-deleting posts
Effect of changing the WordPress site URL
How to determine performance bottleneck?
Changing discourse from domain to subdomain?
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
Broken image URL paths after changing hostname
Hosted-by-discourse.com .. how to configure / rebake / ssh?
File URLs broken after moving to a different domain
How can I bulk remap/update user email addresses?