Can a Custom Domain name be deleted later?

I have a dns multitenant server for ERPNext.

I added a tenant []

[] is not yet ready for release and use as all of the setup data is still being added and configured. This process will probably take 2 to 3 weeks.

In the mean time, I wanted to add a custom domain name to it so that I could work on it in the real environment but still not have it released to the users. So I ran this command:

bench setup add-domain --site [] []

It worked as expected and I now have 2 different ways to access the erpnext system that is being configured. So to cut off access of the users to [], I temporarily removed the A record from the DNS records for that site. That left only one way to access the site which was []

That is exactly what I wanted… for now.

When I am done with all of the configuration settings and data loading I will remake the correct A record in the DNS records for [].

When I am ready to go live with the site, what command can I use to delete the custom domain [] from the site?

I know I can delete the A record in the DNS records for it, but I also don’t want it laying around in my erpnext tenant. So I was wondering how I could delete that Custom Domain reference?

There does not appear to be a reference in the bench commands for this.

Thanks in advance.


While digging around in the site directories, I noticed that any sites with Custom Domains added to them also have a new section added to their “site_config.json” file that calls out the new added domain name.

Is this the only place it exists? Could I edit out the “domain” section of that file to eliminate the Custom Domain for the tenant, or does it also exist in other places in the system?

Is there an undocumented command for bench to delete the Custom Domain? I do not see one in the cheat sheet list of commands.



To the best of my knowledge, there is no specific command to delete the domain added.

You would need to edit the site_config file manually and then once you have done that you will need to bench setup nginx & sudo service nginx reload for the new changes to take effect.


Thanks. Well, at least I found the right place to edit.

I will try that and report back. Thanks fir the helpful hints.


Re-visiting this original question because of a unique problem I have encountered.

I found the need to start running a complete mirror duplicate one of my ERPNExt servers that only supports a single client. When things go wrong on the internet (DDoS attacks on DNS servers, backbone outages in local areas, service interruption at hosting site, and other such “inconveniences”) they wanted a way to quickly switch to a backup, but didn’t want to spend the very high dollars required for a complex automated switching solution.

So, we setup a second identically provisioned VPS server with the hosting company, but in another location. We then made a image backup of the running promary install and restored it to the new server.

In doing so, “everything” was copied faithfully and restored. This includes the Custom Domain name that was originally assigned to the first install. So, in order to make this work we want to re-issue the Custom Domain name of the new backup server.

If the primary server is:


Then we want to set the custom domain of the second server to be:


However, to do this we need to be able to first remove the custom domain name that is left over in the new image from the previous system.

So, I am looking for ideas.

  • I cannot leave the original custom domain there because it might interfere later.
  • I believe that I can “add” a second custom domain name to this to get the new name that we want.
  • I just do not know for sure how to get rid of the custom domain name that is already there.

Regardless of you opinion of how we are going to run this spare server scenario, it is what the client requested so we just need to make it happen.

We have already figured out how to generate an hourly database backup and push it to a waiting directory on the hot spare server. In the event of another system outage, they can simply restore the last pushed database backup and re-do whatever might have been lost over the previous hour at worst case.

  • Is the solution elegant? - No
  • Will it work? - Yes, quite well.
  • Does it cost a lot of money? - No, just the extra server fee. Very cheap comparatively.
  • What’s to be gained of such a solution? - Easing the mind of the users - PRICELESS

So, any ideas on how to manage this Custom Domain Name change would be greatly appreciated.

Thanks to all that take the time to read and offer help.


1 Like

I have not used the custom domain feature but you should be able to log into your MySQL server and see how many DB’s exist. In your case probably two. Duplicate the second DB. This will create mydbname.copy. Drop the original second DB and then edit the site_config file and bench setup nginx & sudo service nginx. This should remove second ERPNext site. Is that what you are trying to achieve?

Just reread your post. Can’t you just edit your zone file to include fail over to server B’s IP address? There are numerous ways to automate this via third party IP service. This way when primary server goes down the fail over service sees this and routes all traffic to server B? You shouldn’t need to delete https:\ then.

Well, not exactly true.

  • In order for that to work there would have to be a live syncing of the erpnext database between the 2 servers. That is NOT a simple process. In order to keep it simple, I just automatically run an hourly backup and “scp” the sql.gz file to the backup host. In the event of a failure on the primary, I just restore the latest backup on the backup host and everyone logs into the backup. At worst case, they re-do the last hour of work. The automated system you speak of requires much, much more work in order to keep the databases so tightly synced.

  • And the reason I need to delete the old domain name that was assigned with the “bench setup add-domain” command is the 2nd server is an exact clone copy of the primary server but is on a different IP host. So the original FQDN cannot be valid on two different hosts on two different IP addresses. That would be an illegal condition. So after firing up the cloned host on the second server I need to be able to wipe out the domain name that carried over from the original host when the disk was imaged. This way I can apply a new name to the backup host.


Still looking for a way to remove the old domain name references from the system so I can add a new one.


Does editing site_config file not work?
Doing a Find within your Coding app should return any other instances.
Via SQL, Check to see if seperate DB was created during process. If not a search within your site DB should return any related entries. All files will be linked in DB.


As far as I know, there is no specific command to “remove” an old domain, you can however replace an old domain with a new one using the following command

bench setup add-domain --site your.old-site

After you have replace the old domain with the new domain you may have to manually check and remove the old domain from the nginx config file in frappe and you You would then need to update your nginx config file as follows:

bench setup nginx
sudo service nginx reload

As a sidenote to your solution, it would have been way much easier and involve less moving parts to have done replication (Master - Slave Setup) via the DBs, which would have mirrored your live server to the backup instantenously. I’ve done it a few times and works well.

Hope this helps

Not sure that would have done the job. That would have made he databases identical, but the rest of the system would be different. I have many custimizations and app changes built into my live production server, and I do not have a way to install an identical program on another server. Since the installation of erpnext is constantly changing, my locked version (10.18) would install as something much newer and without all of my specialized custom work. I paid a developer company to do much of the work and they update my live server for me when a new app or program is changed.

The only way I could absolutely capture an exact opy of my current runing programs on the live server was to do a complete image backup of the VPS server and restore it to another VPS server of identical configuration. Now I am positive I have everything that was on my live production server also running on my backup and test server.

That is why I went through so much trouble to get to this point.

Thanks for the update about changing a domain name. That will be useful in the future for sure.


hi @bkm, did you find a solution to this problem?

Yes, the answer was in the thread above, but I never went back to mark it as the solution. I have done that now so you and others can benefit from it.


I found an easier way to do this:
(i) Adding domain name in frappe nginx configurations
bench setup add-domain [domain-name] --site [site-name]
(ii) Removing or Deleting a domain name in frappe nginx configurations
bench setup remove-domain [domain-name] --site [site -name]

Once you have done this, regenerate the nginx configurations, restart nginx and reload nginx:
bench setup nginx
sudo service nginx restart
sudo service nginx reload

So you are saying that repeating the bench setup add-domain command deletes the domain name it had previously set?!?

That is not very intuitive and it doesn’t sound like something I would expect from bench.


Sorry i missed the part of remove i.e in order to delete use command:
bench setup remove-domain [domain-name] --site [site -name]
I have however made an edit to my previous comments please check the commands again