N8n running locally in Docker and Redis running locally natively

I have n8n running with docker-compose and it works well. Now I want to be able to store and retrieve keys and values from Redis. It works with a cloud hosted Redis but I want to do it locally.

I have Redis locally on port *:6379 and configured in n8n as localhost:6379. This is not working for me, it doesn’t seem to be able to see my localhost.

If it helps to clarify things I’m attempting to use localhost only because n8n is running on the same machine as Redis.

Hey @pigeonflight,

As you are using Docker chances are localhost will resolve to the docker container not the actual machine running Docker, Assuming you are not running Redis in the n8n container this will be why it is failing.

You could try setting the host for redis to the machines IP or maybe 172.17.0.2 which I think is the Docker loopback.

Okay… when I try that I get:

ERROR: Redis connection to 172.17.0.1:6379 failed - connect ECONNREFUSED 172.17.0.1:6379

Hey @pigeonflight,

Try 172.17.0.2 it might be worth just using the actual machine IP though.

I updated the redis configuration (/etc/redis/redis.conf) to use a password and commented out
the bind 127… entry so that it listens on all interfaces.

/etc/redis/redis.conf

requirepass ...supersecure-not-the-real-password...
# bind 127.0.0.1 ::1

It now connects.
Everything is behind a firewall, so it should be fine.

1 Like

I’d love to see the loopback approach work though.

It should work assuming docker is allowing it.