Redis raise error: NOAUTH Authentication required

2020-02-08 05:18发布

I got error NOAUTH Authentication required when I connect to Redis server via command: redis-cli and run ping to check if Redis is working.

I found answer for NOAUTH Authentication required error which describes that this error only happens when Redis is set a password, but I checked Redis config file at etc/redis/redis.conf and there is no password setting.

Redis config

Does anyone know that if there are other settings which can cause this error? Thanks for any help.

p/s: I am using Ruby on Rails web framework, Redis database is used for Sidekiq.

Edited: Redis version is 2.8.4. Server is hosted on AWS.

Currently, I decided to set a password for Redis server so that it can not be set password when it is running.

(When Redis server is restarted, it will work normal. You can run sudo service redis-server restart to restart Redis server.)

6条回答
放荡不羁爱自由
2楼-- · 2020-02-08 05:57

I had the same issue (running on AWS) and discovered our redis port was exposed. You probably had the same. Someone was messing around.

EDIT: The solution: reset your redis password and then (assuming you have it running as a service) restart the service providing the new password

查看更多
欢心
3楼-- · 2020-02-08 05:57

I Have the same problem. after that I'm set requirepass for the redis server.
And add that password in initializer/redis.rb

$redis = Redis.new(:password=>"****") 

It works fine

查看更多
神经病院院长
4楼-- · 2020-02-08 06:07

If you have made any changes in configuration file then don't forget to restart redis service with sudo service redis-server restart command.

Edit: If you are running redis service in production mode then redis requires password to run. For that you need to set password in your config file present at /etc/redis.

You need to set requirepass ******* in that file under ########### SECURITY ############ section.

Then restart your server sudo service redis-server restart.

After that add that password in your config or initializer file where you have set your hostname and port. Example:

$redis = Redis.new(:host => 'localhost', :port => 6379, :password => "*******")

查看更多
We Are One
5楼-- · 2020-02-08 06:07

I Have the same problem, I found it's caused by someone started redis by another redis.cnf configure file, So I stoped redis-server and then started redis-server specify a configure file.

redis-server /etc/redis.cnf

Then every thing works fine.

查看更多
聊天终结者
6楼-- · 2020-02-08 06:09

Had the exact same problem running Redis on an AWS instance. I would restart redis-server without any password requirements (#requirepass ''), would work fine for a few hours, then would throw "NOAUTH Authentication required" and eventually would have to restart redis-server.

Checked the Security Groups settings in AWS for the instance and saw port 6379 open to the public (0.0.0.0/0). We limited the port access to our only server that needs to access and haven't seen the issue come up ever since!

P.S. This is my first ever contribution to StackOverflow. Thanks for the help!

查看更多
走好不送
7楼-- · 2020-02-08 06:17

We also faced a similar issue. Looks like someone went and scanned AWS and connected to all public redis and possibly ran "CONFIG SET REQUIREPASS ''", thus locking down the running instance of redis. Once you restart the redis, the config is restored to normal.

Best thing would be to use AWS security group policy and block port 6379 for public.

查看更多
登录 后发表回答