a year ago
Description: Deploy v1.* of Twenty CRM on Railway
Category: Productivity
URL: https://railway.app/template/nAL3hA
Please check the following docs of Twenty as well when setting up this template:
Using workflows
If you want to use workflows you must configure some type of S3 compatible storage. This is because the Twenty
and Twenty Worker
need access to the same persistent storage, which is not possible (yet) on Railway (storage volumes are only accessible by 1 service).
You can host your own S3 compatible storage on Railway like Minio: https://railway.com/deploy/SMKOEA. Or use any other S3 compatible cloud storage like AWS S3 or Cloudflare R2.
Then setup the following env vars in both the Twenty
andTwenty Worker
services:
STORAGE_TYPE
:"S3"
STORAGE_S3_REGION
: your regionSTORAGE_S3_NAME
: your nameSTORAGE_S3_ENDPOINT
: your s3 endpointSTORAGE_S3_ACCESS_KEY_ID
: your access key idSTORAGE_S3_SECRET_ACCESS_KEY
: your secret key
Versioning:
NOTE: By default the template always deploys the latest docker image: twentycrm/twenty:latest
. But you can pin the deployments to a specific version by updating the source image of both the Twenty and Twenty Worker services. Example: twentycrm/twenty:v1.1.1
.
Find all the versions available here: https://hub.docker.com/r/twentycrm/twenty/tags
Add a comment in this thread if you run into any issues with deploying
54 Replies
a year ago
Does this template support the google auth features?
a year ago
Yes it does, but you'd need to add the env variables yourself. I think this should help: https://twenty.com/developers/section/self-hosting/self-hosting-var check the "Auth" section
a year ago
I tried deploying the Twenty CRM template and provided the 4 email env variables but both my Twenty and Twenty Worker deployments crashed. The Deployment logs on both show the error
``` ERROR [ExceptionHandler] connect ECONNREFUSED 127.0.0.1:6379
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete]```
a year ago
So after checking the github code, I noticed some recent changes from this week and last week that introduced Redis cache storage. To get everything working, I had to add a Redis database to the environment and set the REDIS_HOST
and REDIS_PORT
environment variables for both the Twenty server and the Twenty Worker. It might be helpful to include this setup in the template so future users can have everything working out of the box.
a year ago
Hi, so after I tried deploying with the redis server, I get the following error in my deploy logs:
```Error: getaddrinfo ENOTFOUND redis.railway.internal
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) { errno: -3007, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'redis.railway.internal' }
```
Any ideas how to fix this?
a year ago
Hi, so after I tried deploying with the redis server, I get the following error in my deploy logs:
```Error: getaddrinfo ENOTFOUND redis.railway.internal
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) { errno: -3007, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'redis.railway.internal' }
```
Any ideas how to fix this?
Hi, thanks for the suggestion, I added Redis to the template.
I am however getting the same error as you. I tried adding sleep 3 && yarn start:prod
as the start command as per: https://docs.railway.app/guides/private-networking#initialization-time but then the container does not start properly.
Did you manage to find a fix in the meantime?
It seems the services are unable to reach the Redis instance, I am unsure why though..
a year ago
Unfortunately I have not found a fix yet.
I tried adding the sleep 3 in the start command as well and also adding it in the twenty dockerfile and using my custom docker image instead for the server source image, but that did not work either.
I also saw that bullmq is being used in the message-queue.module-factory files and I found out that bullmq uses ioredis and I saw that the railway documentation mentions :ioredis is a Redis client for node.js, commonly used for connecting to Redis from a node application. When initializing a Redis client using ioredis, you must specify family=0 in the connection string to support connecting to both IPv6 and IPv4 connections
so I tried to add family: 0
in the code where the REDIS_HOST, REDIS_PORT
environment variables are used and then using a custom docker image again, but that did not work either.
Maybe I configured it wrong when trying out these solutions and you have better luck!
I'll keep experimenting and will update here if I find a solution, but if you happen to discover something in the meantime, please let me know as I'm currently stuck and unable to deploy my services
a year ago
I also saw that bullmq is being used in the message-queue.module-factory files and I found out that bullmq uses ioredis and I saw that the railway documentation mentions :
ioredis is a Redis client for node.js, commonly used for connecting to Redis from a node application. When initializing a Redis client using ioredis, you must specify family=0 in the connection string to support connecting to both IPv6 and IPv4 connections
Thanks for pointing me to this! It seems that this is indeed what is causing the error. I added the MESSAGE_QUEUE_TYPE
var and set it to pg-boss
(default is bullmq) so it does not use bullmq and therefore also not ioredis, which seems to fix the redis connection issue. Not the ideal solution but at least the application works
Let me know if this works for you!
a year ago
Yes, that worked for me!
Another approach I tried successfully was deploying the Redis database in a separate environment and connecting to it using the public domain. When I updated the environment variables to point to the public URL, it worked as expected.
I’m still unsure why the internal Redis connection is failing. Do you think this is an issue with Twenty or Railway? If you manage to find the root cause, please let me know!
a year ago
It's an issue with ioredis.
bullmq uses ioredis internally.
The private network is IPv6 only.
ioredis by default only works with IPv4.
a year ago
I see! Thank you for the help!
a year ago
Hey @thomasmol! Quick question—after deploying the template, are you seeing a NOAUTH Authentication required
error when you try to sign up, log in, or create a workspace? I’m having a bit of trouble getting anything to work on my end.
Any ideas on what might be causing this? Is it possibly also related to Redis? Thanks!
10 months ago
Hi Abdel, I don't think that is related to Redis, what are you seeing in your deploy logs? Did the db migrations run as well?
10 months ago
The deploy logs are working fine but I get the following errors on the front-end when I try to do anything after deploying the app
Attachments
10 months ago
Opened a PR to fix the Redis connection issue: https://github.com/twentyhq/twenty/pull/7736
This will allow connecting to the redis instance with a connection url, so we can append ?family=0
6 months ago
Hello!
Looks like the template uses the outdated Postgres image from twenty, would you mind updating that when you get a chance?
Thanks!
brody
Hello!Looks like the template uses the outdated Postgres image from twenty, would you mind updating that when you get a chance?Thanks!
6 months ago
Done!
6 months ago
Perhaps the template page is still cached, but you've used the twenty-postgres-spilo
image right?
brody
Perhaps the template page is still cached, but you've used the twenty-postgres-spilo image right?
6 months ago
yes i did!
Attachments
6 months ago
Noticed the Postgres service only has two variables, the password being set to a crazy insecure value of twenty
, can you add a regular Postgres database into the template and then update its image, this is so that it will have all the proper variables configured.
Then you will need to update the URL reference variable on the twenty services.
brody
Noticed the Postgres service only has two variables, the password being set to a crazy insecure value of twenty, can you add a regular Postgres database into the template and then update its image, this is so that it will have all the proper variables configured.Then you will need to update the URL reference variable on the twenty services.
6 months ago
Thanks for noticing. Its updated
6 months ago
Deployment health of this template seems to be pretty low currently. Help me out and reply here with any issues you are encountering!
6 months ago
Have you tried deploying your template? I did that and can see clear crashes.
6 months ago
Fixed a few errors:
Added missing
APP_SECRET
env var for the worker service (auto gen secret of length 32)
Changed the
DATABASE_URL
andDATABSE_PUBLIC_URL
env vars of the db service to start withpostgres://
(previouslypostgreseql://
, which caused a validation error)
However the db service seems to not start properly. I get /etc/runit/runsvdir/default/patroni: sleeping 90 seconds Config is empty
message in the logs and then it shuts down. I am investigating this issue.
moigamijunior
hi! did you got the solution?
6 months ago
I haven't yet unfortunately. Are you getting the same errors?
thomasmol
I haven't yet unfortunately. Are you getting the same errors?
6 months ago
Yes! Sounds like worker cannot connect to DB. I've fixed the envs, but I got the timeout.
thomasmol
I haven't yet unfortunately. Are you getting the same errors?
6 months ago
[Nest] 29 - 02/19/2025, 2:19:01 PM ERROR [TypeOrmModule] Unable to connect to the database (core). Retrying (4)...
Error: connect ECONNREFUSED fd12:e62c:e118::ac:6a89:25f5:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)
moigamijunior
[Nest] 29 - 02/19/2025, 2:19:01 PM ERROR [TypeOrmModule] Unable to connect to the database (core). Retrying (4)...Error: connect ECONNREFUSED fd12:e62c:e118::ac:6a89:25f5:5432at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)
6 months ago
Yes that is because the database service is not healthy actually. The service says 'Active', but check the deploy logs of the db and you'll see it is not live. Can you share the logs you see there?
thomasmol
Yes that is because the database service is not healthy actually. The service says 'Active', but check the deploy logs of the db and you'll see it is not live. Can you share the logs you see there?
6 months ago
PermissionError: [Errno 13] Permission denied: '/var/lib/postgresql/data/pgdata'
brody
Noticed the Postgres service only has two variables, the password being set to a crazy insecure value of twenty, can you add a regular Postgres database into the template and then update its image, this is so that it will have all the proper variables configured.Then you will need to update the URL reference variable on the twenty services.
6 months ago
Did not manage to get it working with this suggestion. Eventually removed the db service and built a new one directly from the twenty postgres spilo image, instead of creating a regular railway based postgres db and then manually changing the image.
That fixed the db connecting issue.
However, there is another problem, now in the twenty server service, which according to the official docker compose now uses 2 volumes. I can't seem to get it working yet and i get this error in the the deploy logs: touch: /app/docker-data/db_status: No such file or directory
which makes sense because it is only mounted to /app/packages/twenty/data
and you can't mount to two volumes. If you mount the volume to app/docker-data
you'll get an error saying the entrypoint.sh
is missing. Any ideas how to fix this issue?
thomasmol
Did not manage to get it working with this suggestion. Eventually removed the db service and built a new one directly from the twenty postgres spilo image, instead of creating a regular railway based postgres db and then manually changing the image.That fixed the db connecting issue.However, there is another problem, now in the twenty server service, which according to the official docker compose now uses 2 volumes. I can't seem to get it working yet and i get this error in the the deploy logs: touch: /app/docker-data/db_status: No such file or directory which makes sense because it is only mounted to /app/packages/twenty/data and you can't mount to two volumes. If you mount the volume to app/docker-data you'll get an error saying the entrypoint.sh is missing. Any ideas how to fix this issue?
6 months ago
I got something working but it is not ideal:
Updated the 'Twenty' to also include the
APP_SECRET
env var. The twenty worker now refers to the twenty service for this var.Postgres service volume is now mounted on
/home/postgres/pgdata
and based on the twenty spilo image.Added a few env vars to the Postgres service:
SPILO_PROVIDER
,ALLOW_NOSSL
andPGUSER_SUPERUSER
,PGPASSWORD_SUPERUSER
and updated some var values like db name, so it is the same as in the official twenty docker compose
The template now seems to run, but the main 'Twenty' service still has the db_status error. It does run the db migrations properly.
So to get it working you first run the template as is. Then after in the 'Twenty' service you change the start command to yarn start:prod
(db migrations are not run, regardless of the db migration env var), and redploy the service. This should now work.
Running yarn start:prod
as a start command does not execute db migrations.
6 months ago
Can you please bake in migrations into the template, and then have it from start:prod, it's not something the user should need to do.
brody
Can you please bake in migrations into the template, and then have it from start:prod, it's not something the user should need to do.
6 months ago
Yes I understand that perfectly Brody. I have been trying different commands/deploy config and can't get it working yet, and this is the best I can do thus far. Any help is much appreciated.
3 months ago
Recent deployments are close to a 100% success rate, so all looks good now. Also, since version 0.53
, "upgrade is programmatically done within the DockerFile
, this means from now on, you shouldn't have to run any command manually anymore." According to the official Twenty upgrade guides. So a nice change!
2 months ago
Deploys but still having DB issues, not sure if it's just me but can't get this app to work...
Error: Failed to load all config variables: relation "core.keyValuePair" does not exist
self-hosting-var page has been deleted and now 404's
2 months ago
DB still looks unhealthy, unable to connect to it, even through DBeaver afer adding public interface possibility.
UI tries to load but I got error: "Relation "core.user" does not exist".
Guys, please advice how to fix this situation?
Attachments
a month ago
So it seems DB migrations are not properly run. To fix: add yarn database:init:prod
as a Pre-deploy Command on the Twenty service. This should init the db properly and run migrations. @vicwrc: if you go to the postgres service settings and enable TCP Proxy to port 5432
you should be able to connect to it with DBeaver (even without running the pre-deploy command first).
I've updated the template:
- Twenty
service now has yarn database:init:prod
as a Pre-deploy command.
- I added a healthcheck to Twenty
service, it checks path /healthz
You can find the run/deploy/migration commands that are used here: https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/package.json
a month ago
Hello, do we need to setup the cron jobs manually in the worker or is it already done in the template ? (update: just read the above comment that this is handled by docker now so nothing to do)
a month ago
Hey Thomas!
We where talking about your template in Twenty's discord and one of their teammates raised the fact that this template might be deprecated?
https://discord.com/channels/1130383047699738754/1146466959676936192/1393160909530206288
What are your thoughts on that?
a month ago
Bruh, just deployed it 2 days ago and works perfectly fine.
a month ago
--
falz
Bruh, just deployed it 2 days ago and works perfectly fine.
a month ago
Yeah I know, I use it everyday.
jbronssin
Hey Thomas!We where talking about your template in Twenty's discord and one of their teammates raised the fact that this template might be deprecated?https://discord.com/channels/1130383047699738754/1146466959676936192/1393160909530206288What are your thoughts on that?
a month ago
Thanks, I'll take a look. I am not planning to deprecate this template and will keep maintaining for the time being!
a month ago
I've updated the template to use an official Postgres image for the database, as per the docker-compose file provided by Twenty: https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/docker-compose.yml.
Changes:
Updated
Postgres
service source image topostgres:16
Added
PGDATA
variable toPostgres
service with value/var/lib/postgresql/data/pgdata
Updated volume mount path to
/var/lib/postgresql/data/pgdata
ofPostgres
service
Previous deployments with the now deprecated twentycrm/twenty-postgres-spilo
image for the Postgres DB should still work, and don't need to be migrated (if you do, make sure to backup your db)
thomasmol
I've updated the template to use an official Postgres image for the database, as per the docker-compose file provided by Twenty: https://raw.githubusercontent.com/twentyhq/twenty/refs/heads/main/packages/twenty-docker/docker-compose.yml.Changes:Updated Postgres service source image to postgres:16Added PGDATA variable to Postgres service with value /var/lib/postgresql/data/pgdataUpdated volume mount path to /var/lib/postgresql/data/pgdata of Postgres servicePrevious deployments with the now deprecated twentycrm/twenty-postgres-spilo image for the Postgres DB should still work, and don't need to be migrated (if you do, make sure to backup your db)
a month ago
Well done mate!
So no need to migrate? Or might it become problematic over time?
jbronssin
Well done mate!So no need to migrate? Or might it become problematic over time?
a month ago
Thank you!
I am not sure, it does not seem like a problem right now, but can't say it won't be in the future. If you want to follow the official way to deploy Twenty you might want to migrate.
Be careful though, backup your db so you can restore if needed after you migrate.
16 days ago
attempted to deploy the template today , but its not working .. something I need to do after I roll it out?
brianspelledwithani
attempted to deploy the template today , but its not working .. something I need to do after I roll it out?
16 days ago
Can you elaborate what you mean? Are you seeing errors? What do they say?
Update:
Seems to be an issue with creating new workspaces on a clean installs. I've created an github issue here: https://github.com/twentyhq/twenty/issues/13676
Deployments should be OK if you already had existing data
Update 2:
Issue has been solved, template can now be deployed again with latest version.
16 days ago
@thomasmol
I wanted to take time to migrate but discovered that I was on postgres:16 already... Was it done automatically ?
jbronssin
@thomasmol I wanted to take time to migrate but discovered that I was on postgres:16 already... Was it done automatically ?
16 days ago
Hmm interesting, I am not aware of templates updates being automatically propagated to existing deployments. Did the migration go OK?
thomasmol
Hmm interesting, I am not aware of templates updates being automatically propagated to existing deployments. Did the migration go OK?
16 days ago
everything is working like a charm