T
Twenty4mo ago
Farrit

twenty can't find its database

I'm trying to run Twenty behind a reverse proxy (traefik) and I have been using a script to help manage/configure it (deplyrr). In doing so, I'm trying to shoe-horn the .env's together by transplanting all of twenty's env variables into my other .env, and use the same ones that I am able to get working with twenty as a standalone stack, AND get twenty to fit into the formatting that deployrr uses - to be able to use the automation that it has setup with traefik... but I keep running into the same issue where the server cannot find the database at the database address. I have all of the services split up into individual yml files (twenty-server.yml, twenty-worker.yml, twenty-db.yml) and redis is already running on my server, and has been associated (I assume correcly.. But I even if I create a second redis container using pre-defined settings, it doesn't seem to help) Can anyone see what I'm doing incorrectly here?
services:
twenty-server:
image: twentycrm/twenty:${TAG:-latest}
profiles: ["all", "twenty"]
volumes:
- $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/.local-storage
networks:
- default
- socket_proxy
ports:
- "$TWENTY_PORT:3000"
environment:
NODE_PORT: 3000
PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379}

STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
STORAGE_S3_NAME: ${STORAGE_S3_NAME}
STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

APP_SECRET: ${APP_SECRET}

depends_on:
twenty-db:
condition: service_healthy
healthcheck:
test: curl --fail http://100.67.242.72:3000/healthz
interval: 5s
timeout: 5s
retries: 20
restart: always

volumes:
db-data:
server-local-data:
services:
twenty-server:
image: twentycrm/twenty:${TAG:-latest}
profiles: ["all", "twenty"]
volumes:
- $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/.local-storage
networks:
- default
- socket_proxy
ports:
- "$TWENTY_PORT:3000"
environment:
NODE_PORT: 3000
PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379}

STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
STORAGE_S3_NAME: ${STORAGE_S3_NAME}
STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

APP_SECRET: ${APP_SECRET}

depends_on:
twenty-db:
condition: service_healthy
healthcheck:
test: curl --fail http://100.67.242.72:3000/healthz
interval: 5s
timeout: 5s
retries: 20
restart: always

volumes:
db-data:
server-local-data:
services:
twenty-worker:
image: twentycrm/twenty:${TAG:-latest}
profiles: ["all", "twenty"]
networks:
- default
- socket_proxy
volumes:
- $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/${STORAGE_LOCAL_PATH:-.local-storage}
command: ["yarn", "worker:prod"]
environment:
PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
DISABLE_DB_MIGRATIONS: "true" # it already runs on the server

STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
STORAGE_S3_NAME: ${STORAGE_S3_NAME}
STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

APP_SECRET: ${APP_SECRET}

depends_on:
twenty-db:
condition: service_healthy
twenty-server:
condition: service_healthy
restart: always

volumes:
db-data:
server-local-data:
services:
twenty-worker:
image: twentycrm/twenty:${TAG:-latest}
profiles: ["all", "twenty"]
networks:
- default
- socket_proxy
volumes:
- $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/${STORAGE_LOCAL_PATH:-.local-storage}
command: ["yarn", "worker:prod"]
environment:
PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379}
DISABLE_DB_MIGRATIONS: "true" # it already runs on the server

STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION}
STORAGE_S3_NAME: ${STORAGE_S3_NAME}
STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

APP_SECRET: ${APP_SECRET}

depends_on:
twenty-db:
condition: service_healthy
twenty-server:
condition: service_healthy
restart: always

volumes:
db-data:
server-local-data:
services:
twenty-db:
image: postgres:16
profiles: ["all", "twenty"]
networks:
- default
- socket_proxy
volumes:
- $DOCKERDIR/appdata/twenty/db-data:/var/lib/postgresql/data
ports:
- "$PG_DATABASE_PORT:5432"
environment:
POSTGRES_USER: ${PG_DATABASE_USER:-postgres}
POSTGRES_PASSWORD: ${PG_DATABASE_PASSWORD:-postgres}
healthcheck:
test: pg_isready -U ${PG_DATABASE_USER:-postgres} -h localhost -d postgres
interval: 5s
timeout: 5s
retries: 10
restart: always

volumes:
db-data:
server-local-data:
services:
twenty-db:
image: postgres:16
profiles: ["all", "twenty"]
networks:
- default
- socket_proxy
volumes:
- $DOCKERDIR/appdata/twenty/db-data:/var/lib/postgresql/data
ports:
- "$PG_DATABASE_PORT:5432"
environment:
POSTGRES_USER: ${PG_DATABASE_USER:-postgres}
POSTGRES_PASSWORD: ${PG_DATABASE_PASSWORD:-postgres}
healthcheck:
test: pg_isready -U ${PG_DATABASE_USER:-postgres} -h localhost -d postgres
interval: 5s
timeout: 5s
retries: 10
restart: always

volumes:
db-data:
server-local-data:
No description
6 Replies
Farrit
FarritOP4mo ago
this is the error I get in the container log (via portainer)
matspi
matspi4mo ago
Your database container (and thus the database host) is called twenty-db, not db, isn't it? The error is about postgres, not redis.
Farrit
FarritOP4mo ago
It is. I change the container back to db? You can tell how new to this I am. Changed my db host to twenty-db and it seems to be working now Man, I'm so used to figuring out complicated and obscure issues with commercial 3d printers and chemistry, that this stuff sometims just flies right over my head or under my radar. Thank you so much. Getting a validation error now. I'm probably messing something else up. I may just give up on this config and try again with caddy instead, the complexity of this makes my head reel.
Node.js v18.17.1

Running database setup and migrations...

[Nest] 56 - 05/27/2025, 1:04:00 PM ERROR SERVER_URL must be a URL address

/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/config-variables.js:1282

throw new _twentyconfigexception.ConfigVariableException('Config variables validation failed', _twentyconfigexception.ConfigVariableExceptionCode.VALIDATION_FAILED);



^

ConfigVariableException [Error]: Config variables validation failed

at Object.validate (/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/config-variables.js:1282:15)

at ConfigModule.forRoot (/app/node_modules/@nestjs/config/dist/config.module.js:67:45)

at TwentyConfigModule.forRoot (/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/twenty-config.module.js:29:34)

at Object.<anonymous> (/app/packages/twenty-server/dist/src/engine/core-modules/core-engine.module.js:76:52)

at Module._compile (node:internal/modules/cjs/loader:1256:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

at Module.load (node:internal/modules/cjs/loader:1119:32)

at Module._load (node:internal/modules/cjs/loader:960:12)

at Module.require (node:internal/modules/cjs/loader:1143:19)

at require (node:internal/modules/cjs/helpers:121:18) {

code: 'VALIDATION_FAILED'

}
Node.js v18.17.1

Running database setup and migrations...

[Nest] 56 - 05/27/2025, 1:04:00 PM ERROR SERVER_URL must be a URL address

/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/config-variables.js:1282

throw new _twentyconfigexception.ConfigVariableException('Config variables validation failed', _twentyconfigexception.ConfigVariableExceptionCode.VALIDATION_FAILED);



^

ConfigVariableException [Error]: Config variables validation failed

at Object.validate (/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/config-variables.js:1282:15)

at ConfigModule.forRoot (/app/node_modules/@nestjs/config/dist/config.module.js:67:45)

at TwentyConfigModule.forRoot (/app/packages/twenty-server/dist/src/engine/core-modules/twenty-config/twenty-config.module.js:29:34)

at Object.<anonymous> (/app/packages/twenty-server/dist/src/engine/core-modules/core-engine.module.js:76:52)

at Module._compile (node:internal/modules/cjs/loader:1256:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

at Module.load (node:internal/modules/cjs/loader:1119:32)

at Module._load (node:internal/modules/cjs/loader:960:12)

at Module.require (node:internal/modules/cjs/loader:1143:19)

at require (node:internal/modules/cjs/helpers:121:18) {

code: 'VALIDATION_FAILED'

}
Prastoin
Prastoin4mo ago
Hello please review your SERVER_URL env var
[Nest] 56 - 05/27/2025, 1:04:00 PM ERROR SERVER_URL must be a URL address
[Nest] 56 - 05/27/2025, 1:04:00 PM ERROR SERVER_URL must be a URL address
Farrit
FarritOP4mo ago
There was an x in the begining of the ip address, I must have fatfingered it when trying to exit nano. Thank you! It's working!
Prastoin
Prastoin4mo ago
Nice ! Enjoy coding !

Did you find this page helpful?