# Changing the hostname

**URL:** https://meta.discourse.org/t/changing-the-hostname/23920
**Category:** Support
**Tags:** docker
**Created:** [January 12, 2015, 6:51pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920 "2015-01-12T18:51:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jarrett](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jarrett](https://meta.discourse.org/u/jarrett)
#### Post date: [January 12, 2015, 6:51pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/1 "2015-01-12T18:51:00Z")

</div>

I installed Discourse with Docker per the official instructions.

At the time of installation, I didn’t have a domain name ready, so I just used an IP address as the hostname. Later, I got the domain name working, and Discourse is accessible via that hostname.

However, the IP address–which is no longer the correct hostname for this installation–still shows up in various places. One such place is outgoing emails. When a user receives a notification of a new post, the link back to the topic has the IP address as the hostname.

I’ve replaced the IP address where I could find it:

- In the host OS at `/var/discourse/containers/app.yml`, the `DISCOURSE_HOSTNAME` key.
- Inside the Docker container at `/var/www/discourse/config/discourse.conf`, the `hostname` key.

I tried `SiteSetting.refresh!` from the Rails console. I also tried restarting the Docker container with `./launcher restart app`.

I see that in `app/views/email/_post.html.erb`, the links go to `Discourse.base_url`. From the Rails console, I see that `Discourse.base_url` is correct:

```
root@discourse:/var/www/discourse# rails console production
irb(main):001:0> Discourse.base_url
=> "http://myhost.example.com"

```

Yet the outgoing emails still have the IP address instead of the correct hostname. Any idea why that would happen, and how it might be fixed?

---

<div class="post-metadata">

### Author: ![ZeroFlux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zeroflux/32/42184_2.png) [@ZeroFlux](https://meta.discourse.org/u/ZeroFlux)
#### Post date: [January 12, 2015, 7:16pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/2 "2015-01-12T19:16:09Z")

</div>

I think rebuilding the container will resolve your issue. Double-check the hostname details in the app.yml and make sure they’re saved to your liking. Then rebuild Discourse’s container, which destroys the old one, bootstraps a new one, and starts it up.

Navigate to the Discourse directory:

```
cd /var/discourse

```

Then use the rebuild command:

```
./launcher rebuild app

```

Hope that helps!

---

<div class="post-metadata">

### Author: ![jarrett](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jarrett](https://meta.discourse.org/u/jarrett)
#### Post date: [January 12, 2015, 7:36pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/3 "2015-01-12T19:36:20Z")

</div>

What becomes of the database upon a rebuild? Does it get wiped out? We already have content we’d like to preserve.

Instead of a rebuild, would it be possible to find where the setting is stored and edit it manually?

---

<div class="post-metadata">

### Author: ![Moter8](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moter8/32/120941_2.png) [@Moter8](https://meta.discourse.org/u/Moter8)
#### Post date: [January 12, 2015, 7:37pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/4 "2015-01-12T19:37:55Z")

</div>

Rebuild preserves the database. If you still are paranoid, just make a backup and download that, it contains all users, posts, etc.

---

<div class="post-metadata">

### Author: ![ZeroFlux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zeroflux/32/42184_2.png) [@ZeroFlux](https://meta.discourse.org/u/ZeroFlux)
#### Post date: [January 12, 2015, 8:01pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/5 "2015-01-12T20:01:54Z")

</div>

Fear not, the database is preserved through rebuilds. The only things that  
could be “lost” are items mentioned in the app.yml. In this case, that  
includes your old IP address! Also, if you ever want to install new  
plugins, that process will also require app rebuilds.

---

<div class="post-metadata">

### Author: ![Eric\_Toombs](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eric\_Toombs](https://meta.discourse.org/u/Eric_Toombs)
#### Post date: [October 1, 2015, 10:03pm UTC](https://meta.discourse.org/t/changing-the-hostname/23920/9 "2015-10-01T22:03:02Z")

</div>

Are you sure a rebuild is necessary? [This post](https://meta.discourse.org/t/how-to-edit-app-yml-file/20569/5) says a rebuild isn’t necessary for any changes to the env section.

update: I changed the hostname and restarted the service without rebuilding. It hasn’t exploded on me yet…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 12, 2018, 1:22am UTC](https://meta.discourse.org/t/changing-the-hostname/23920/10 "2018-11-12T01:22:06Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 12, 2018, 2:47am UTC](https://meta.discourse.org/t/changing-the-hostname/23920/11 "2018-11-12T02:47:02Z")

</div>

Environments updates require you destroy the old container and then start a new one.

This can be done with

```plaintext
./launcher destroy app
./launcher start app

```

People though get confused about this so we usually just prescribe

```plaintext
./launcher rebuild app

```

Which means you eat a bit more of an outage but it works for pretty much everything.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 12, 2018, 2:47am UTC](https://meta.discourse.org/t/changing-the-hostname/23920/12 "2018-11-12T02:47:04Z")

</div>


