# Rebake fails when changing the subdomain name only

**URL:** <https://meta.discourse.org/t/rebake-fails-when-changing-the-subdomain-name-only/128104>\
**Category:** Self-hosting\
**Created:** [September 9, 2019, 10:27pm UTC](https://meta.discourse.org/t/rebake-fails-when-changing-the-subdomain-name-only/128104 "2019-09-09T22:27:28Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![YaserAlnajjar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaseralnajjar/32/100729_2.png) [@YaserAlnajjar](https://meta.discourse.org/u/YaserAlnajjar)\
**Post date:** [September 9, 2019, 10:27pm UTC](https://meta.discourse.org/t/rebake-fails-when-changing-the-subdomain-name-only/128104/1 "2019-09-09T22:27:28Z")

</div>

Hi

I recently copied the `/shared` database folder from our production to staging server (to make both environments match).

I realized the links are pointing to the previous domain, so I followed this [guide](https://meta.discourse.org/t/change-the-domain-name-or-rename-my-discourse/16098)

When running this command inside the container:

```plaintext
discourse remap forums.coretabs.net discourse.coretabs.net

```

I get a `duplicate key value` error:

```plaintext
Rewriting all occurences of forums.coretabs.net to discourse.coretabs.net
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
YES
Error: ERROR: duplicate key value violates unique constraint "index_incoming_domains_on_name_and_https_and_port"
DETAIL: Key (name, https, port)=(discourse.coretabs.net, t, 443) already exists.
The remap has only been partially applied due to the error above. Please re-run the script again.

```

---

_[View the full topic](https://meta.discourse.org/t/rebake-fails-when-changing-the-subdomain-name-only/128104)._
