Connect to an external database server¶
On the existing database server, create a new database for Mathesar to store its metadata.
DJANGO_DATABASE_URLenvironment variable to point to the database you just created.
(Optional) For Docker Compose related installations, you may disable Mathesar’s default database server if you like.
Connect to a database server running on the host¶
If you’re running Mathesar in a Docker related environment, and your database server runs on the host machine, you will not be able to connect to it using
localhost would refer to the Docker environment and not to the host.
You can try using
host.docker.internal instead of
localhost. Below are detailed instructions to expose the database on your host to the Docker instance.
pg_hba.conffile on the host machine. This can be located using
psqlshell by executing the following respectively.
Find the appropriate IP addresses of the
docker0interface and the
mathesar_defaultinterface. This can be found by exectuting the following in the host’s terminal.
Stop Mathesar if it’s already running.
postgresql.conffile and add the IP of
docker0interface in the
listen_addressessetting. Uncomment this line if it’s conmmented out.
pg_hba.conffile and grant access to the
mathesar_defaultinterface. Add the following line at the bottom of the file:
Set the value of
MATHESAR_DATABASESenvironment variable to the following:
If your Mathesar installation is Docker Compose based, add an extra host for the prod container in the
You should have a successful connection to the host database now!