Can't host Twenty - twenty-db-1 is unhealthy
Hey, I've been following this guide here via Option 2.
https://twenty.com/developers/section/self-hosting/docker-compose
I use Portainer to host it.
In the end I run into the following error:
Pull complete server Pulled worker Pulled Network twenty_default Creating Network twenty_default Created Container twenty-change-vol-ownership-1 Creating Container twenty-db-1 Creating Container twenty-change-vol-ownership-1 Created Container twenty-db-1 Created Container twenty-server-1 Creating Container twenty-server-1 Created Container twenty-worker-1 Creating Container twenty-worker-1 Created Container twenty-change-vol-ownership-1 Starting Container twenty-db-1 Starting Container twenty-change-vol-ownership-1 Started Container twenty-db-1 Started Container twenty-db-1 Waiting Container twenty-change-vol-ownership-1 Waiting Container twenty-change-vol-ownership-1 Exited Container twenty-db-1 Error dependency failed to start: container twenty-db-1 is unhealthy
It's the same compose and env file as in the example and changed the strings as asked.
35 Replies
Hi there, do you have any error log on the database container ?
If not, another lead could be that by default the health check expect the database to be healthy in about 50s, depending on your setup it might be a bit too short.
I can't get it deployed so there's no container yet. :/
I set it up to 150 seconds. Still no success though.
Still the same error.
Tried removing the health check to see any error logs:
postgresql 09:41:44.99 ERROR ==> The POSTGRESQL_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow the container to be started with blank passwords. This is recommended only for development.Tried setting the password on the stack and container. In both cases the environment for the container doesn't take it it seems.
It just nulls the password and/or the ALLOW_EMPTY_PASSWORD flag.
The logs of the server:
[Nest] 1 - 09/13/2024, 9:44:47 AM ERROR [TypeOrmModule] Unable to connect to the database (metadata). Retrying (9)... Error: getaddrinfo ENOTFOUND db at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) [Nest] 1 - 09/13/2024, 9:44:47 AM ERROR [ExceptionHandler] getaddrinfo ENOTFOUND db Error: getaddrinfo ENOTFOUND db at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26)As URL I tried it with http://localhost:3000 and http://server.local:3000 (how I'll actually access it in the end)
It seems to try to resolve the database address using 'db'.
Iβm not familiar with portainer, but I would say that the right domain in your case would be twenty-db-1
You could try to update the PG_DATABASE_HOST env?
[Nest] 1 - 09/13/2024, 11:02:20 AM ERROR [ExceptionHandler] getaddrinfo ENOTFOUND twenty-db-1 Error: getaddrinfo ENOTFOUND twenty-db-1 at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26)Basically the same error. Though that's probably because the db can't run?
postgresql 11:02:54.76 INFO ==> Starting PostgreSQL setup postgresql 11:02:54.78 INFO ==> Validating settings in POSTGRESQL_* env vars.. postgresql 11:02:54.78 ERROR ==> The POSTGRESQL_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow the container to be started with blank passwords. This is recommended only for development. postgresql 11:02:54.78 ERROR ==> The POSTGRESQL_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow the container to be started with blank passwords. This is recommended only for development.The network settings say that they're all in the same network but the database doesn't seem to get any address.
Portainer in generell is just an interface that basically does the commands via UI. So there shouldn't be any difference. It's a regular Docker compose.
Then ok the domain isnβt the issue π
On your screen I see the db as running, but you donβt have any meaningful log? Itβs not hanging either?
The DB error is the POSTGRESQL_PASSWORD issue
And the DB can't draw a network address either. The server and worker can.
Oh I see, have you tried to set the POSTGRES_ADMIN_PASSWORD env?
Ah, yeah. Now it's running. Just asked ChatGPT as well and gave me that info haha.
Might want to add that to the startup guide.
Okay, now the three are running - the "twenty-change-vol-ownership-1" exits itself.
How do I access the twenty interface now?
http://server.local:3000/ refuses the connection.
localhost:3000 doesnβt do the trick? (Or server.local is binded to localhost?)
Ah, the server gives me an error again:
[Nest] 1 - 09/13/2024, 11:20:06 AM ERROR [ExceptionHandler] JwtStrategy requires a secret or key TypeError: JwtStrategy requires a secret or key at new JwtStrategy (/app/node_modules/passport-jwt/lib/strategy.js:45:15) at new MixinStrategy (/app/node_modules/@nestjs/passport/dist/passport/passport.strategy.js:32:13) at new JwtAuthStrategy (/app/packages/twenty-server/dist/src/engine/core-modules/auth/strategies/jwt.auth.strategy.js:86:9) at Injector.instantiateClass (/app/node_modules/@nestjs/core/injector/injector.js:351:19) at callback (/app/node_modules/@nestjs/core/injector/injector.js:56:45) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Injector.resolveConstructorParams (/app/node_modules/@nestjs/core/injector/injector.js:136:24) at async Injector.loadInstance (/app/node_modules/@nestjs/core/injector/injector.js:61:13) at async Injector.loadProvider (/app/node_modules/@nestjs/core/injector/injector.js:88:9) at async /app/node_modules/@nestjs/core/injector/instance-loader.js:56:13Ah, whoops, I know that one I think. Yup. I added by local env.env with the tokens but they were still commented out so they weren't there. :facepalm: Okay, runs now. Thank you very much!
π€©
Okay, next issue though.
As per documentation I wasn't able to login so I ran
docker exec -it twenty-server-1 yarnBefore that: And so on.
Try
docker exec -it twenty-server-1 yarn install
Yeah, that returned me this:
(...)
If you need the entire log, let me know but I think you probably know what the issue might be seeing this.
Actually itβs getting a bit out of my scope π
I'd appreciate if you'd have someone who's scope involves this. π
But thank you so far nevertheless! At least I was able to run the application once. x)
The team is quite busy at this time, Iβll try to repro locally
Much appreciated
Actually it doesn't seem to be a blocking issue, did you try to run the next command in the guide ?
I got the same error but was able to reset db
Yeah, I did but the application doesn't start afterwards:
And can't access the application from web anymore either.
Okay, I deleted the volumes and just literally restart the entire thing and now it works.
Weird.
But yeah, I'm able to use and enter data now. I guess some sort of hickup. x)
I'm wondering if the
database:reset
job resets everything and requires to run migration again, it seems from the log that the database was in poor state π
Well I'm glad you got to start the app !
should have been good so hard to say then@Quentin G @Dultus we should actually not do yarn in production. Everything is built as it should be in the container. Could we remove this from the doc?
Same for the database reset, we should NEVER do that on production.
There is yarn database:init:prod command to be run the first time, which is already part of the setup script
So @Dultus don't do the yarn and the reset, could you restart your setup without doing it, and from there if you stil have the login issue, could you share with us the error you have in your network tab (browser developer console)
Yeah it requires installing a lot of dependencies, Iβll check if we can run migration without doing a yarn install
I mean it does work now! π
I don't know why the login worked though. After all I didn't change anything and deleted the volumes.
so it's all good on your side @Dultus ?
@Quentin G we should not have to do a yarn install? Why do we need it?
Yup!
I donβt know to be honest, itβs legacy stuff that was here before me in the doc π
ok! I think we should remove them and we should be all good!
If someone faces an issue again we should fix the root cause but not recommending to run yarn as everythin is pre-bundled
@Dultus great! closing the thread