-
Notifications
You must be signed in to change notification settings - Fork 5
DB setup for production
vukilelanga edited this page Feb 26, 2026
·
1 revision
For production instances, docker-compose will not start a database container. You need to supply your own postgresql DB, either on the same host as your docker containers or a separate host.
When setting up a postgresql DB for production, ensure that the following steps are done:
- Ensure postgres has a database available for kotahi, with an appropriate user set up as owner. The database name, user name and user password need to be configured in the .env file (
POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB). Also configure (POSTGRES_HOSTandPOSTGRES_PORT). -
postgresql.confshould havelisten_addressesset to either'*'(less secure) or the specific IP address of the host interface that Docker can reach (more secure). - If postgres is running on the same host as the docker containers,
pg_hba.confshould contain an entry allowing connections fromhost all all 172.17.0.0/16 md5(substituting your actual docker range, which you can find by runningip addrfrom within a docker container, look for theeth0entry's inet value, e.g.172.17.0.2/16, and change the last digit of the IP to 0, e.g.172.17.0.0/16). - If running postgres remotely,
pg_hba.confneeds an entryhost all all 192.168.12.34/32 md5(substituting the host interface that your docker containers run on / can reach). In some cases this appears to be needed even when the containers and postgres are on the same host! - In both these cases, you can make the
pg_hba.confentries more secure by restricting to a specific user/database, e.g.host mydb myuser 172.17.0.0/16 md5. - Make sure postgres is restarted to apply changes. Rebuild Kotahi if you've changed the
.envfile.
Troubleshooting:
- From inside your server container, attempt to connect to the DB using psql:
psql -h <host> -p <port> -U <db-username> -d <db-database>. (To enter the server container if it has stopped, you can list all images usingdocker ps, find the server container's image name, then run the server interactively usingdocker run -it <server-image> /bin/bash.) - Failing that, from inside your server container attempt to reach the database host/port using netcat:
nc -zv <db-host> <db-port>(e.g.nc -zv 192.168.12.34 5432). This should report 'open' if it's reachable. - Failing that, check for firewall or network security settings that might prevent communication.