twenty
twenty copied to clipboard
Redis Connection Error: ECONNREFUSED at 127.0.0.1:6379 Causing Service Failure
Bug Description
When running the application, a connection error occurs with Redis, causing the service to exit. This issue happens because the application cannot connect to 127.0.0.1:6379, resulting in an ECONNREFUSED error in the logs.
ERROR [ExceptionHandler] connect ECONNREFUSED 127.0.0.1:6379
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)
Expected behavior
The application should successfully connect to Redis at 127.0.0.1:6379, or an alternative Redis instance if configured, without raising connection errors. The application should start and run as expected without interruption.
Technical inputs
- The application is configured to connect to Redis on the localhost (127.0.0.1) at port 6379.
- The issue might be fixable by:
- Ensuring Redis is running on the expected address and port.
- Checking firewall settings or Docker container networking if Redis runs in a container.
- Updating environment configurations if Redis is hosted remotely.
other info
- Hosting : render.com
- version twenty:server : Latest
- Render.yaml Blueprint
# Exported from Render on 2024-10-12T14:37:13Z
services:
- type: worker
name: twenty:worker
runtime: image
image:
url: docker.io/twentycrm/twenty:latest
creds:
fromRegistryCreds:
name: dockerhub
plan: standard
envVars:
- key: REFRESH_TOKEN_SECRET
sync: false
- key: LOGIN_TOKEN_SECRET
sync: false
- key: FILE_TOKEN_SECRET
sync: false
- key: ACCESS_TOKEN_SECRET
sync: false
- fromGroup: Twenty
region: oregon
dockerCommand: yarn run worker:prod
- type: web
name: twenty:server
runtime: image
image:
url: docker.io/twentycrm/twenty:latest
creds:
fromRegistryCreds:
name: dockerhub
plan: standard
envVars:
- key: REFRESH_TOKEN_SECRET
sync: false
- key: LOGIN_TOKEN_SECRET
sync: false
- key: FILE_TOKEN_SECRET
sync: false
- key: ACCESS_TOKEN_SECRET
sync: false
- fromGroup: Twenty
region: oregon
dockerCommand: yarn run start:prod
disk:
name: disk
mountPath: /.local-storage
sizeGB: 5
version: "1"
Hey @KazeroG - we don't officially maintain the Render.yaml but a pull request would be most welcome! It seems it's missing a redis in Render.yaml https://docs.render.com/redis
I am having the same issue with the docker compose version from the docs. I have checked that I can connect to the redis service from the host computer. And both containers are in the same docker network
Yes that's the issue, you're looking at the .env/documentation for main, while the docker version is still the old one :-/. Ideally one day we should have versioned docs that match the last published version
Ahhh, alright. So waiting a bit and it should all sync up with the docs
Yes it should! Sorry
I've got this issue. Not sure from the discussion what the fix is; wait for an update to the docker compose?
@JTCorrin use the .env.example variable from the latest published version and not the one from the main branch, (so this one https://github.com/twentyhq/twenty/blob/v0.31.3/packages/twenty-server/.env.example)
Damn took me 6 hours till found this hahaha
Closing as the new docker image has been published. A fix for Render would be most welcome! We might prioritize one but not short-term as we're still focused on adding new features/making the platform more stable and bug-free. Thanks for the report!
Is there an updated docker compose to go with this env file?
Hey @JTCorrin you mean this one https://github.com/twentyhq/twenty/blob/main/packages/twenty-docker/docker-compose.yml ? What makes you think it's not up-to-date? Thanks
Hey @FelixMalfait , thanks for the speedy response.
Well off the bat that docker compose file expects a PG_DATABASE_HOST:
PG_DATABASE_URL: postgres://twenty:twenty@${PG_DATABASE_HOST}/default
In the env file the only var resembling that is : PG_DATABASE_URL=postgres://twenty:twenty@localhost:5432/default
There are a few examples of the same. Unless I'm being an idiot (which is very possible!) this docker compose file does not align with the env file
Hey @JTCorrin no problem, I'm not very good with docker either 😅
There are the "docker level" env variable and then those are used to generate the app-level env variables. I don't think it's really outdated but there's something unclear with the current architecture, I agree we should improve that.
PG_DATABASE_HOST is useful is you wanted to host the db on another network, but in your case with a simple docker compose you probably want to leave it to db:5432 or whetever is the default
I think I see where I'm going wrong - I'm getting the environment variables mixed up here!
Thanks for helping me work through it @FelixMalfait , much appreciated
Just wanted to follow up to say the compose up command now give me a "db unhealthy" when starting up. I'm going to step away from this now but thanks for the assistance!