Cannot suddenly connect to my Redis service from my web service and worker.
energieman
HOBBYOP

3 months ago

It has been working quite alright for the last (almost) 2 months. This error suddenly started by itself 24 hours ago without deploying or touching anything.

I have redeployed, rolledback, restarted and done everything possible but the connection still times-out.

I am not a free user.
My worker project dependencies are

"dependencies": {
    "bullmq": "^5.1.0",
    "ioredis": "^5.3.2",
    "dotenv": "^16.3.1"
  },

Again, I didnt touch/deploy anything, and I didnt do anything. Any new deployment is after the error while trying to rollback or redeploy.

Below is the error log from my worker (same error with my web service)

at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)

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

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

at Socket._onTimeout (node:net:595:8)

at listOnTimeout (node:internal/timers:581:17)

at process.processTimers (node:internal/timers:519:7) {

errorno: 'ETIMEDOUT',

code: 'ETIMEDOUT',

syscall: 'connect'

}

error: Worker error {"error":"connect ETIMEDOUT","service":"hne-worker","stack":"Error: connect ETIMEDOUT\n at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)\n at Object.onceWrapper (node:events:638:28)\n at Socket.emit (node:events:524:28)\n at Socket._onTimeout (node:net:595:8)\n at listOnTimeout (node:internal/timers:581:17)\n at process.processTimers (node:internal/timers:519:7)","timestamp":"2025-12-03 06:48:07"}

error: Worker error {"error":"connect ETIMEDOUT","service":"hne-worker","stack":"Error: connect ETIMEDOUT\n at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)\n at Object.onceWrapper (node:events:638:28)\n at Socket.emit (node:events:524:28)\n at Socket._onTimeout (node:net:595:8)\n at listOnTimeout (node:internal/timers:581:17)\n at process.processTimers (node:internal/timers:519:7)","timestamp":"2025-12-03 06:48:07"}

electric_plug emoji Worker Redis connection closed

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

at Socket._onTimeout (node:net:595:8)

at listOnTimeout (node:internal/timers:581:17)

x emoji Worker Redis error: Error: connect ETIMEDOUT

at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)

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

at process.processTimers (node:internal/timers:519:7) {

error: Worker error {"error":"connect ETIMEDOUT","service":"hne-worker","stack":"Error: connect ETIMEDOUT\n at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)\n at Object.onceWrapper (node:events:638:28)\n at Socket.emit (node:events:524:28)\n at Socket._onTimeout (node:net:595:8)\n at listOnTimeout (node:internal/timers:581:17)\n at process.processTimers (node:internal/timers:519:7)","timestamp":"2025-12-03 06:48:20"}

errorno: 'ETIMEDOUT',

electric_plug emoji Worker Redis connection closed

code: 'ETIMEDOUT',

syscall: 'connect'

}

error: Worker error {"error":"connect ETIMEDOUT","service":"hne-worker","stack":"Error: connect ETIMEDOUT\n at Socket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:171:41)\n at Object.onceWrapper (node:events:638:28)\n at Socket.emit (node:events:524:28)\n at Socket._onTimeout (node:net:595:8)\n at listOnTimeout (node:internal/timers:581:17)\n at process.processTimers (node:internal/timers:519:7)","timestamp":"2025-12-03 06:48:20"}

Solved

2 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


energieman
HOBBYOP

3 months ago

Hi, your resources from the thread was helpful, the problem is fixed now.
It worked after adding 'family: 0' to the ioredis connection configuration.
Meanwhile my app has worked fine for 2 months without adding that, only to suddenly fail overnight.
Here is my final (working) connection code

const Redis = require('ioredis');

function createRedisConnection() {
  const config = {
    host: process.env.REDIS_HOST || 'localhost',
    port: parseInt(process.env.REDIS_PORT) || 6379,
    db: parseInt(process.env.REDIS_DB) || 0,
    family: 0, // <---------- I added this
    maxRetriesPerRequest: null,
    enableReadyCheck: false, 
  };

  if (process.env.REDIS_PASSWORD) {
    config.password = process.env.REDIS_PASSWORD;
  }

  const redis = new Redis(config);

  redis.on('connect', () => {
    console.log('✅ Worker Redis connected');
  });

  redis.on('error', (err) => {
    console.error('❌ Worker Redis error:', err);
  });

  redis.on('close', () => {
    console.log('🔌 Worker Redis connection closed');
  });

  return redis;
}

module.exports = { createRedisConnection };


Status changed to Solved ray-chen 3 months ago


Loading...