Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run docker:start can't connect to Redis #483

Open
ghost opened this issue Jun 28, 2023 · 1 comment
Open

npm run docker:start can't connect to Redis #483

ghost opened this issue Jun 28, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 28, 2023

Brief Description
npm run docker:start can't connect to Redis

Severity
Low

Steps to Reproduce
in .env set

REDIS_HOSTNAME=redis

Try to run locally with docker

Expected Results/Behaviour
You see

{ name: 'redisConnect', value: 'Redis: Connection to redis ready' }

Actual Results/Behaviour

Redis: Unable to connect to the redis database:  ConnectionTimeoutError: Connection timeout

Workaround


diff --git a/config/redis.js b/config/redis.js
index 3c64d21..20545d3 100644
--- a/config/redis.js
+++ b/config/redis.js
@@ -3,9 +3,9 @@ import config from './config.js';
 
 let connectionOptions = {};
 // https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-best-practices-connection
-if (config.REDIS_KEY && config.REDIS_HOSTNAME) {
+if (config.REDIS_HOSTNAME) {
     connectionOptions = {
-        url: `rediss://${config.REDIS_HOSTNAME}:${config.REDIS_PORT}`,
+        url: `redis://${config.REDIS_HOSTNAME}:${config.REDIS_PORT}`,
         password: config.REDIS_KEY,
         socket: {
             connectTimeout: 5000,

First line change needed as there is no key and we still want to set up all the fancy stuff.

Second line change needed as there is no SSL on the Redis Docker.

I guess we'll need to add a config.REDIS_SSL option

@ghost
Copy link
Author

ghost commented Jun 29, 2023

Or we assume production always uses SSL and dev never does, and after line 29 just add:

} else {
    connectionOptions = { url: `redis://${config.REDIS_HOSTNAME}:${config.REDIS_PORT}` }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants