How to change the domain in the database

If your database contains the wrong domain, the Application will produce a 400 error on every call (“Invalid Host“)

There are multiple methods to change the domain name in the database to fix the problem.

1. Using DB management tools like:

PgAdmin or DBeaver

 

Once connected to the Database find and open the table django_site . Edit the domain field and set the domain name.

 

2. Using the command line:

Connect to the DB server via SSH. Connect to the psql CLI utility by running the following command:
$ psql
Once connected list the available Schemes
postgres-# \l

To establish a connection to the Schema
\c kurl

To check the domain and its ID in the database run this query:

select * from django_site;

To update the domain name(myDomain.xxx) run this query:

UPDATE public.django_site SET "domain"='my-new-domain.xxx' WHERE id=2;

 

3. Using the application to connect to the database and change the domain name

You can change the domain name by establishing a connection from the button3D pod(container) to the database. To achieve that you would need to do the following:

  1. SSH to the server where the application is running

  2. To find the pod(container) name of button3d you need to do the following
    For Kurl.sh deployments:
    run kubectl get pods and copy the name of button3d pod

  • execute kubectl exec -i -t $(kubectl get pods | grep "button3d" | cut -d" " -f1) -- sh and you should see something like this:

    user@hostname:~$ kubectl exec -i -t $(kubectl get pods | grep "button3d" | cut -d" " -f1) -- sh /var/www/django $
  • To connect to the database run /bin/entry ./manage.py dbshell

  • To find the domains in the DB run the following query: select * from django_site;

  • To change the domain run the following:

  • You should see the new domain now: