# Changing hostname

**URL:** https://meta.discourse.org/t/changing-hostname/260954
**Category:** Self-hosting
**Created:** [April 7, 2023, 4:20pm UTC](https://meta.discourse.org/t/changing-hostname/260954 "2023-04-07T16:20:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ibahnasy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibahnasy/32/301452_2.png) [@ibahnasy](https://meta.discourse.org/u/ibahnasy)
#### Post date: [April 7, 2023, 4:20pm UTC](https://meta.discourse.org/t/changing-hostname/260954/1 "2023-04-07T16:20:24Z")

</div>

I exported a bit old version of Discourse container and the Discourse docker files from a running instance and imported it on a different server.  
I need to change Discourse hostname to match the new server.

- Is there a way to make the new `DISCOURSE_HOSTNAME:` effective without a rebuild?
- If I must rebuild, will that fetch the latest version from `main` branch and override the current version I have? because I need run exactly the current version.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 7, 2023, 4:29pm UTC](https://meta.discourse.org/t/changing-hostname/260954/2 "2023-04-07T16:29:32Z")

</div>

Hi Islam 🙂

> [@ibahnasy](#):
>
> Is there a way to make the new `DISCOURSE_HOSTNAME:` effective without a rebuild?

Not that I know.

> [@ibahnasy](#):
>
> If I must rebuild, will that fetch the latest version from `main` branch and override the current version I have?

Yes, it will.

You may find related information here for what you want to achieve: [Search results for 'install version discourse' - Discourse Meta](https://meta.discourse.org/search?q=install%20version%20discourse)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 7, 2023, 5:57pm UTC](https://meta.discourse.org/t/changing-hostname/260954/3 "2023-04-07T17:57:29Z")

</div>

You’d need to change stuff in the let’s encrypt config, which is (at least part of) why you need to rebuild.

Why not upgrade? That’s what you really need to do. Just how old is it?

But you could contrive to pin `discourse_docker` (aka `/var/discourse` and the Discourse version that you’re on. You might also need to pin all of the plugins.

If you’ve got something else doing the https resolution then you might be able to avoid the rebuild and just do the other stuff in [Change the domain name or rename your Discourse](https://meta.discourse.org/t/change-the-domain-name-or-rename-your-discourse/16098).

---

<div class="post-metadata">

### Author: ![ibahnasy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibahnasy/32/301452_2.png) [@ibahnasy](https://meta.discourse.org/u/ibahnasy)
#### Post date: [April 7, 2023, 6:38pm UTC](https://meta.discourse.org/t/changing-hostname/260954/4 "2023-04-07T18:38:47Z")

</div>

I need to have the same version on that instance to test upgrading to the latest version so if succeeded, will preform the upgrade on production.

> If you’ve got something else doing the https resolution then you might be able to avoid the rebuild and just do the other stuff in [Change the domain name or rename your Discourse](https://meta.discourse.org/t/change-the-domain-name-or-rename-your-discourse/16098).  
> HTTPS is handled on a load balancer, but that link saying I have to rebuild after modifying app.yml.

- So if I will pin the versions, for `discourse_docker`, I should checkout the current commit hash?
- And for Discourse app inside the container, I should also set it’s current commit hash using `version: <commit_hash>` in app.yml?
- What about plugins?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 7, 2023, 7:03pm UTC](https://meta.discourse.org/t/changing-hostname/260954/5 "2023-04-07T19:03:02Z")

</div>

> [@ibahnasy](#):
>
> I need to have the same version on that instance to test upgrading to the latest version so if succeeded, will preform the upgrade on production.

It’s a good bet that if you install the current version on the testing server and restore the database to it that you can upgrade the production server.

What you’re proposing is likely several hours of work, has a bunch of confusing little bits that will be very hard to describe in a forum, and isn’t going to prove anything that restoring the production database to the new server isn’t going to do.

Just point the staging server and the production server to the same S3 backup bucket, backup production and restore it to the staging server. Going forward, they’ll be in parity and you can upgrade staging and production in rapid succession.

---

<div class="post-metadata">

### Author: ![ibahnasy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibahnasy/32/301452_2.png) [@ibahnasy](https://meta.discourse.org/u/ibahnasy)
#### Post date: [April 7, 2023, 7:24pm UTC](https://meta.discourse.org/t/changing-hostname/260954/6 "2023-04-07T19:24:33Z")

</div>

I triggered a rebuild but this is what I got:

```plaintext
I, [2023-04-07T19:17:58.707365 #1] INFO -- : > cd /var/www/discourse && gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' Gemfile.lock)
ERROR: Could not find a valid gem 'bundler' (= 2.3.4), here is why:
          Unable to download data from https://rubygems.org/ - Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)

```

However I can curl [rubygems.org](http://rubygems.org) from host.

---

<div class="post-metadata">

### Author: ![ibahnasy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibahnasy/32/301452_2.png) [@ibahnasy](https://meta.discourse.org/u/ibahnasy)
#### Post date: [April 10, 2023, 1:13pm UTC](https://meta.discourse.org/t/changing-hostname/260954/7 "2023-04-10T13:13:02Z")

</div>

Any suggestions on the above error?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 10, 2023, 4:22pm UTC](https://meta.discourse.org/t/changing-hostname/260954/8 "2023-04-10T16:22:02Z")

</div>

Did you to a command line rebuild? Is this a [standard install](https://meta.discourse.org/t/142537?silent=true)?

---

<div class="post-metadata">

### Author: ![ibahnasy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibahnasy/32/301452_2.png) [@ibahnasy](https://meta.discourse.org/u/ibahnasy)
#### Post date: [April 10, 2023, 4:52pm UTC](https://meta.discourse.org/t/changing-hostname/260954/9 "2023-04-10T16:52:48Z")

</div>

Yes, rebuild command and also initiated upgrade from GUI gave the same error.

```plaintext
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)>

There was an error installing the locked bundler version (2.4.4), rerun with the `--verbose` flag for more details. Going on using bundler 2.3.6.
Fetching source index from https://rubygems.org/

Could not fetch specs from https://rubygems.org/ due to underlying error
<Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)>
Docker Manager: FAILED TO UPGRADE

```
