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"] ))