I
Immich•2y ago
ankitnayan

Unable to point Immich to use Redis externally

Hi, I have Redis already running and want to point Immich to use Redis externally. I have commented out redis in the docker-compose file of Immich and set the REDIS_HOSTNAME=redis (name of redis container), REDIS_PORT=6379, REDIS_USERNAME=username (redacted), REDIS_PASSWORD=password (redacted), REDIS_DBINDEX=1 in the .env file but is not working. Do I need to explicitly mention the above env variables for the immich_server and immich_microservices? Authelia runs perfectly fine while using Redis but when I point Immich to use Redis externally it breaks. All the container runs under the traefik proxy network. My docker-compose.yml and .env files are attached.
21 Replies
ankitnayan
ankitnayanOP•2y ago
Error from immich_microservices:
Error: connect ECONNREFUSED 172.18.0.4:6379 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '172.18.0.4', port: 6379
Error from immich_server:
[Nest] 8 - 07/27/2023, 10:13:59 AM ERROR [RedisIoAdapter] Redis pubClient: Error: connect ECONNREFUSED 172.18.0.4:6379 [Nest] 8 - 07/27/2023, 10:13:59 AM ERROR [RedisIoAdapter] Redis subClient: Error: connect ECONNREFUSED 172.18.0.4:6379
bo0tzz
bo0tzz•2y ago
It can't reach the address that redis is at
ankitnayan
ankitnayanOP•2y ago
Yes, the immich is unable to reach Redis externally but Authelia reaches the Redis externally with the Redis hostname and port, and username, password.
bo0tzz
bo0tzz•2y ago
Then something must be different between the two, probably in the network setup
ankitnayan
ankitnayanOP•2y ago
If I use immich_redis (i.e 2 different redis) both works but when pointing Immich to Redis externally, both breaks. i.e Authelia is unable to authenticate and so does Immich Redis compose file
--- version: "3.7" services: redis: image: redis:latest container_name: redis command: redis-server /data/redis.conf ports: - 6379:6379 volumes: - './config:/data' environment: - TZ=Asia/Kolkata - ALLOW_EMPTY_PASSWORD=no restart: unless-stopped security_opt: - no-new-privileges:true networks: - traefik_proxy labels: - "com.centurylinklabs.watchtower.enable=true" networks: traefik_proxy: external: true
bo0tzz
bo0tzz•2y ago
Do the redis logs have any clues?
ankitnayan
ankitnayanOP•2y ago
Apart from the below nothing shows when both breaks
1:C 27 Jul 2023 14:26:00.302 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 27 Jul 2023 14:26:00.303 # Redis version=7.0.12, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 27 Jul 2023 14:26:00.303 # Configuration loaded 1:M 27 Jul 2023 14:26:00.304 * monotonic clock: POSIX clock_gettime 1:M 27 Jul 2023 14:26:00.306 # Warning: Could not create server TCP listening socket ::1:6379: bind: Cannot assign requested address 1:M 27 Jul 2023 14:26:00.307 * Running mode=standalone, port=6379. 1:M 27 Jul 2023 14:26:00.307 # Server initialized 1:M 27 Jul 2023 14:26:00.314 * Loading RDB produced by version 7.0.12 1:M 27 Jul 2023 14:26:00.314 * RDB age 2 seconds 1:M 27 Jul 2023 14:26:00.314 * RDB memory usage when created 0.85 Mb 1:M 27 Jul 2023 14:26:00.314 * Done loading RDB, keys loaded: 0, keys expired: 0. 1:M 27 Jul 2023 14:26:00.314 * DB loaded from disk: 0.000 seconds 1:M 27 Jul 2023 14:26:00.314 * Ready to accept connections
While pinging Redis I'm able to reach it. Do I need to explicitly mention the REDIS env variables for the immich_server and immich_microservices in docker-compose?
jrasm91
jrasm91•2y ago
What do you mean by this? I would assume if you want to use the service or container name, that it needs to be in the same docker network. In your above example the redis container is added to the proxy network. Is that where authelia is running?
ankitnayan
ankitnayanOP•2y ago
Yes, Authelia and Immich both are running under same proxy network Nvm, pls ignore this. I meant that when I ping the Redis responds means redis is working.
jrasm91
jrasm91•2y ago
What container is this from?
1:M 27 Jul 2023 14:26:00.306 # Warning: Could not create server TCP listening socket ::1:6379: bind: Cannot assign requested address
ankitnayan
ankitnayanOP•2y ago
from Redis
jrasm91
jrasm91•2y ago
The non-immich one?
ankitnayan
ankitnayanOP•2y ago
Yes
jrasm91
jrasm91•2y ago
Well, it isn't listening on port 6379
ankitnayan
ankitnayanOP•2y ago
bind 127.0.0.1 -::1 This is mentioned in redis.conf file. I think I need to get rid of -::1? Seems this is for ipv6, right?
jrasm91
jrasm91•2y ago
Idk, but it sounds like redis is not actually available/accessible, which is why immich can't connect to it. Unless that error is specifically for ipv6 and it is listening on the same port on ipv4
ankitnayan
ankitnayanOP•2y ago
Let me check if I can see and fix that. After getting rid of -::1, below is the logs from redis
1:C 27 Jul 2023 18:41:28.529 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 27 Jul 2023 18:41:28.529 # Redis version=6.2.12, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 27 Jul 2023 18:41:28.529 # Configuration loaded 1:M 27 Jul 2023 18:41:28.532 * monotonic clock: POSIX clock_gettime 1:M 27 Jul 2023 18:41:28.535 * Running mode=standalone, port=6379. 1:M 27 Jul 2023 18:41:28.535 # Server initialized 1:M 27 Jul 2023 18:41:28.543 * Loading RDB produced by version 6.2.12 1:M 27 Jul 2023 18:41:28.543 * RDB age 10 seconds 1:M 27 Jul 2023 18:41:28.543 * RDB memory usage when created 0.81 Mb 1:M 27 Jul 2023 18:41:28.543 # Done loading RDB, keys loaded: 0, keys expired: 0. 1:M 27 Jul 2023 18:41:28.543 * DB loaded from disk: 0.001 seconds 1:M 27 Jul 2023 18:41:28.543 * Ready to accept connection
jrasm91
jrasm91•2y ago
Nice. And immich-server still cannot connect/start?
ankitnayan
ankitnayanOP•2y ago
This is now disappeared No, still no luck 😦
jrasm91
jrasm91•2y ago
Is it the same error? Can you verify the ip in the error is the ip of the redis container?
ankitnayan
ankitnayanOP•2y ago
No, the ip has changed Could be because I redeployed Redis Looks like the error is fixed, could be some issue with any of the config in redis.conf file. I removed it and redeployed Redis without redis.conf file. Okay, so restarted the server and immich_server and immich_microservices is able to communicate with redis. It seems there could be some config in redis.conf file which prevented immich services from connecting to redis. Thank you for helping! Cheers 🙂

Did you find this page helpful?