Redis: keeps connecting to 127.0.0.1 instead of defined host


#1

I’d like my sessions to be stored in Redis. However, I keep getting connect ECONNREFUSED 127.0.0.1:6379. And that’s weird because in config/redis I defined host as redis (this works in another Docker container).

SESSION_DRIVER=redis
connection: Env.get('REDIS_CONNECTION', 'local'),

  /*
  |--------------------------------------------------------------------------
  | local connection config
  |--------------------------------------------------------------------------
  |
  | Configuration for a named connection.
  |
  */
  local: {
    host: 'redis',
    port: 6379,
    password: Env.get('REDIS_PASSWORD'),
    db: 0,
    keyPrefix: ''
  },

I used adonis install @adonisjs/redis and added the provider like mentioned in the docs. When I change my SESSION variable to cookie everything works fine.

Any ideas?


#2

Fixed!

In config/sessions.js I had to update redis: 'self::redis.default' to redis: 'self::redis.local'.

@virk I’ve created a pull request to fix this: https://github.com/adonisjs/adonis-fullstack-app/pull/8


#3

Merged PR, should be good now