Microservices not connecting to database

Hello there, with the recent updates i went to migrate and everything but the microservices seems to be working.
Docker compose is attached and the error in the microservices log is:
[Nest] 6 - 09/21/2023, 9:50:03 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...

Error: Connection terminated due to connection timeout

at Connection.<anonymous> (/usr/src/app/node_modules/pg/lib/client.js:132:73)

at Object.onceWrapper (node:events:628:28)

at Connection.emit (node:events:514:28)

at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:63:12)

at Socket.emit (node:events:514:28)

at TCP.<anonymous> (node:net:323:12)

Error: getaddrinfo ENOTFOUND immich_redis

at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'immich_redis'

}

Error: getaddrinfo ENOTFOUND immich_redis

at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'immich_redis'

}
[Nest] 6 - 09/21/2023, 9:50:03 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...

Error: Connection terminated due to connection timeout

at Connection.<anonymous> (/usr/src/app/node_modules/pg/lib/client.js:132:73)

at Object.onceWrapper (node:events:628:28)

at Connection.emit (node:events:514:28)

at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:63:12)

at Socket.emit (node:events:514:28)

at TCP.<anonymous> (node:net:323:12)

Error: getaddrinfo ENOTFOUND immich_redis

at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'immich_redis'

}

Error: getaddrinfo ENOTFOUND immich_redis

at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'immich_redis'

}
Any help would be appreciated.
6 Replies
Alex Tran
Alex Tran•2y ago
Try to bring down all containers related to Immich, then bring them up again
DrPhilOrpheus
DrPhilOrpheusOP•2y ago
I have tried. I've fully removed all containers and let it rebuild them, still nothing. I double checked the dependencies but still no dice. I've also tried hardcoding the IP's of the postgres and redis instances in the db_host and redis_host variables.
bo0tzz
bo0tzz•2y ago
Is your redis container running? Do its logs have any errors?
DrPhilOrpheus
DrPhilOrpheusOP•2y ago
yes it is
1:C 22 Sep 2023 13:23:15.780 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

1:C 22 Sep 2023 13:23:15.780 # Redis version=6.2.12, bits=64, commit=00000000, modified=0, pid=1, just started

1:C 22 Sep 2023 13:23:15.780 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

1:M 22 Sep 2023 13:23:15.781 * monotonic clock: POSIX clock_gettime

1:M 22 Sep 2023 13:23:15.781 * Running mode=standalone, port=6379.

1:M 22 Sep 2023 13:23:15.781 # Server initialized

1:M 22 Sep 2023 13:23:15.781 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

1:M 22 Sep 2023 13:23:15.782 * Ready to accept connections
1:C 22 Sep 2023 13:23:15.780 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

1:C 22 Sep 2023 13:23:15.780 # Redis version=6.2.12, bits=64, commit=00000000, modified=0, pid=1, just started

1:C 22 Sep 2023 13:23:15.780 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

1:M 22 Sep 2023 13:23:15.781 * monotonic clock: POSIX clock_gettime

1:M 22 Sep 2023 13:23:15.781 * Running mode=standalone, port=6379.

1:M 22 Sep 2023 13:23:15.781 # Server initialized

1:M 22 Sep 2023 13:23:15.781 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

1:M 22 Sep 2023 13:23:15.782 * Ready to accept connections
its logs all the other containers, except for the microservices seems to work
bo0tzz
bo0tzz•2y ago
It's not added to the same network as the rest
DrPhilOrpheus
DrPhilOrpheusOP•2y ago
oh snap! you're right I knew it had to be something simple who'd of guessed putting it in the same network would fixed it 😛 thanks for the help (and making me feel like a big dummy, realizing how much time i wasted looking at other stuff).

Did you find this page helpful?