# ODK Central - Changing domain names

**URL:** <https://forum.getodk.org/t/odk-central-changing-domain-names/37655>\
**Category:** Support\
**Tags:** odk-central\
**Created:** [May 13, 2022, 10:50am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655 "2022-05-13T10:50:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saad](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/saad/32/4537_2.png) [@Saad](https://forum.getodk.org/u/Saad)\
**Post date:** [May 13, 2022, 10:50am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/1 "2022-05-13T10:50:27Z")

</div>

Hi,

I have setup ODK Central on a certain domain (e.g. [abc.com](http://abc.com)), and now want the same installation to work under another domain (e.g. [xyz.com](http://xyz.com)) [Please note that it is a migration, and not an effort to run both in parallel at the same time]. The server and IP address remains the same, so I just need to map the old IP address to the new sub-domain. What changes do I need to make in Central configuration? Is it just the change in .env file, to update to new URL? I assume I would have to do 'docker-compose build' as well afterwards? Would it hurt the existing forms data present in the Central? Any other changes needed?

I see a relevant link here ([Can I change my domain name after Installing ODK Central?](https://forum.getodk.org/t/can-i-change-my-domain-name-after-installing-odk-central/36855)) but no confirmed answer. Did you try it and it worked fine @iamnarendrasingh?

Thanks,  
Saad

---

<div class="post-metadata">

**Author:** ![iamnarendrasingh](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/iamnarendrasingh/32/2593_2.png) [@iamnarendrasingh](https://forum.getodk.org/u/iamnarendrasingh)\
**Post date:** [May 16, 2022, 5:08am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/2 "2022-05-16T05:08:55Z")

</div>

Hey @Saad ,

I hope you are well and safe. I follow the below steps:

1. Login into Cloud(Digital Ocean/AmazonEC2) and open .env file
2. Open the registered domain DNS page with IP address information.
3. Update .env file accordingly.
4. Run the "docker-compose build" command and restart docker.
5. In my case it took nearby 5-10 minutes to reflect on the new server.

Best,  
@iamnarendrasingh

---

<div class="post-metadata">

**Author:** ![Saad](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/saad/32/4537_2.png) [@Saad](https://forum.getodk.org/u/Saad)\
**Post date:** [May 16, 2022, 12:29pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/3 "2022-05-16T12:29:30Z")

</div>

Any data loss risk possible to happen?

---

<div class="post-metadata">

**Author:** ![yanokwa](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/yanokwa/32/1695_2.png) [@yanokwa](https://forum.getodk.org/u/yanokwa)\
**Post date:** [May 16, 2022, 9:32pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/4 "2022-05-16T21:32:48Z")

</div>

I haven't verified recently, but everything in Enketo is bound to the domain, so I'm pretty sure public access links (and maybe even previews) will not work if you rebuild with a new domain.

It's possible that re-uploading a new version of each form with an incremented version number will fix it, but I haven't tested that workaround.

Worst case scenario, you'll need to go into the Redis DBs at `central_enketo_redis_main_1` and `central_enketo_redis_cache_1` and manually replace the old domain name with the new. Not straightforward to do, but doable.

Try this on a backup first.

---

<div class="post-metadata">

**Author:** ![iamnarendrasingh](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/iamnarendrasingh/32/2593_2.png) [@iamnarendrasingh](https://forum.getodk.org/u/iamnarendrasingh)\
**Post date:** [May 18, 2022, 5:36am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/5 "2022-05-18T05:36:04Z")

</div>

Hey, @Saad as @yanokwa mentioned only public access links and script which I created to download raw data from the server affected. And I rebuild them in my case I did not have any data loss on my side. One more thing, I am not using any other database server for maintaining the datasets.

Best,  
@iamnarendrasingh

---

<div class="post-metadata">

**Author:** ![manghig](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/manghig/32/11609_2.png) [@manghig](https://forum.getodk.org/u/manghig)\
**Post date:** [August 8, 2023, 6:33pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/6 "2023-08-08T18:33:18Z")

</div>

> [@yanokwa](#):
>
> I haven't verified recently, but everything in Enketo is bound to the domain

Hi,  
so I guess that a single Central installation cannot be accessed and used using more than 1 domain name, correct?

thanks in advance.

---

<div class="post-metadata">

**Author:** ![Saad](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/saad/32/4537_2.png) [@Saad](https://forum.getodk.org/u/Saad)\
**Post date:** [August 8, 2023, 7:33pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/7 "2023-08-08T19:33:48Z")

</div>

Theoretically no. Central setup asks for domain name during installation and its also bound by SSL certificates. You 'may' setup a redirect from another domain, but the main domain will remain the same. You won't be able to replicate many things, especially the server address in the collect app associated with long form names.

---

<div class="post-metadata">

**Author:** ![yanokwa](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/yanokwa/32/1695_2.png) [@yanokwa](https://forum.getodk.org/u/yanokwa)\
**Post date:** [August 8, 2023, 8:30pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/8 "2023-08-08T20:30:12Z")

</div>

You can have two domains pointed to the same install.

To do that, have [example1.com](http://example1.com) and [example2.com](http://example2.com) pointed to the same IP.

Then put [example1.com](http://example1.com) in your `~/central/.env` file.

```auto
SSL_TYPE=letsencrypt
DOMAIN=example1.com

```

Then in `~central/files/nginx/odk.conf.template`, make this change in line 3.

```diff
- server_name ${CNAME};
+ server_name ${CNAME} example2.com;

```

I've only tried this with LetsEncrypt as an SSL type. Your mileage may vary with other types.

---

<div class="post-metadata">

**Author:** ![manghig](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/manghig/32/11609_2.png) [@manghig](https://forum.getodk.org/u/manghig)\
**Post date:** [August 9, 2023, 7:52am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/9 "2023-08-09T07:52:36Z")

</div>

> [@yanokwa](#):
>
> You can have two domains pointed to the same install.

Thanks for the tip! I will try that and let you know how it went!

---

<div class="post-metadata">

**Author:** ![danielpintosalazar](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danielpintosalazar/32/28611_2.png) [@danielpintosalazar](https://forum.getodk.org/u/danielpintosalazar)\
**Post date:** [October 28, 2024, 7:29pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/10 "2024-10-28T19:29:07Z")

</div>

**Migrating ODK Central Server to a New Domain**

Hi, @Saad and @yanokwa. I migrated an ODK Central server hosted on a DigitalOcean droplet to a new domain. Here are the steps I followed:

**Steps to Migrate the Server**

**1. Generate a Snapshot**  
Create a snapshot of the current droplet where ODK Central is located. This will serve as a backup and a base for the new droplet.

**2. Create a New Droplet**  
Launch a new droplet using the snapshot created in the previous step.

**3. Update Domain in .env File**  
Modify the `.env` file to include the new domain names. Make sure that your DNS is pointing to the new IP address of the server.

**4. Rebuild Docker Containers**  
Run the following command to rebuild and start your ODK containers:  
`docker-compose up -d --build`

**5. Update Redis Databases**  
Update the Redis databases `central_enketo_redis_main_1` and `central_enketo_redis_cache_1` to reflect the new domain.

**Updating the Domain in Redis**

To update the domain, I used the following Bash script, based on this [tutorial](https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk). This script updates keys and values in Redis to replace the old domain with the new one. I recommend follow all steps of the tutorial, don't forget create a backup.

```auto
#!/bin/sh

OLD_DOMAIN="old-domain.com"
NEW_DOMAIN="new-domain.com"

keys=$(redis-cli -p 6379 KEYS "*")

for key in $keys
do
  if ["$(redis-cli -p 6379 type "$key")" = "string"]; then
    if echo "$key" | grep -q "$OLD_DOMAIN"; then
      new_key=$(echo "$key" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 RENAME "$key" "$new_key"
    fi
  elif ["$(redis-cli -p 6379 type "$key")" = "hash"]; then
    existingRosaServer=$(redis-cli -p 6379 HGET "$key" "openRosaServer")
    if echo "$existingRosaServer" | grep -q "$OLD_DOMAIN"; then
      newRosaServer=$(echo "$existingRosaServer" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 HSET "$key" "openRosaServer" "$newRosaServer"
    fi

    if echo "$key" | grep -q "$OLD_DOMAIN"; then
      new_key=$(echo "$key" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 RENAME "$key" "$new_key"
    fi
  fi
done

```

Key Resources: [https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk](https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk)

---

<div class="post-metadata">

**Author:** ![Tyler\_Depke](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tyler_depke/32/17598_2.png) [@Tyler\_Depke](https://forum.getodk.org/u/Tyler_Depke)\
**Post date:** [January 13, 2026, 11:06am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/11 "2026-01-13T11:06:51Z")

</div>

> [@yanokwa](#):
>
> Then in `~central/files/nginx/odk.conf.template`, make this change in line 3.
> 
> ```auto
> - server_name ${CNAME};
> + server_name ${CNAME} example2.com;
> 
> ```

In doing this, a Web Forms/Enketo form can only be accessed from the ${CNAME} domain and not the [example2.com](http://example2.com) domain, correct?

I recently made a post asking about [this](https://forum.getodk.org/t/one-odk-central-instance-many-domains-per-project-domain/57380)
