2

I searched and found some post related about this problem, espacially this one NOAUTH Authentication required. Laravel + Redis, but it doesn't solved my problem.

Redis + Rails ( with dotenv-rails ) + Ubuntu

Errors:

Redis::CommandError (NOAUTH Authentication required.)

In development the app is OK, but in production ( deploy with cap ) got this error.

In production with Redis without password the app is OK, but add password got this error.

etc/redis/redis.conf :

bind 127.0.0.1
requirepass somepassword

.env

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=somepassword
REDIS_PORT=6379

config/initializers/redis.rb

Redis.current = Redis.new(:host => ( ENV["REDIS_HOST"] || '127.0.0.1'),
                          :port => ( ENV["REDIS_PORT"] || '6379').to_i,
                          :password => (ENV["REDIS_PASSWORD"] || ''))

And I test the ENV["REDIS_HOST"] in rails console, output is 127.0.0.1.

I want to know how to enable Redis's password in this situation?

Thanks


EDIT

I run auth the_password in redis-cli, the ouput is OK and same as the value of ENV["REDIS_PASSWORD"] from the production rails console.

And now the rails log display Redis::CommandError (ERR invalid password) .

I'm very confused about it.

Edit again

I changed redis.rb to below and it worked:

Redis.current = Redis.new(:host => ( ENV["REDIS_HOST"] ),
                          :port => ( ENV["REDIS_PORT"] ).to_i,
                          :password => ( ENV["REDIS_PASSWORD"] ))
floox
  • 351
  • 4
  • 21
  • Are you sure your environment variables are loading properly? You can check these variable in rails console in productiom environment and check for these values if they are loaded properly or not – Aakash Gupta Nov 13 '17 at 17:11
  • There are same. I run `auth the_password` in `redis-cli`, the ouput is `OK` and same as the value of `ENV["REDIS_PASSWORD"]` from the production rails console. And now the rails log display `Redis::CommandError (ERR invalid password)` . – floox Nov 13 '17 at 22:12
  • Check output of `ENV['REDIS_PASSWORD']` in RAILS CONSOLE in production environment. I'm not talking about redis console. – Aakash Gupta Nov 14 '17 at 07:38
  • Thank you @AakashGupta . Now it's OK after I did some changes like in the **Edit again** . – floox Nov 14 '17 at 12:42

0 Answers0