I recently came across this query regarding starting redis-server on a different port than the default 6379 in Ubuntu. I am currently trying to achieve the same using ioredis
in my NestJS
project, but unfortunately, it refuses to connect to any other port except 6379. I do not have a separate Redis Server running as I rely on ioredis
. However, for testing purposes, I need to run a distinct instance that does not operate on port 6379.
The code snippet below executes without any issues:
const redis = new Redis();
const redis = new Redis('localhost');
const redis = new Redis(6379);
With this code, I can perform all the necessary tasks.
However, when I attempt to run the following code:
const redis = new Redis(6380);
const redis = new Redis(6380, 'localhost');
I encounter the subsequent error:
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6380
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Do I need to explore different instantiation options within ioredis
? Or could this issue be related to NestJS? Although I am aware of NestJS's documentation on Redis which mentions port 6379, why am I unable to make the basic example from the ioredis
API guide function correctly?