DENIED error
Protected mode refused a connection from another computer, because the server has no password.
Redis sends this error when a client on another computer connects to a server in protected mode. Protected mode is on by default. While it's on, and the default user has no password, Redis only accepts connections from its own computer, through the loopback interface (127.0.0.1 or ::1). It sends this error to any other connection, and then closes the connection.
DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Set up an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
Some client libraries don't show this message. For example, redis-py only reports ConnectionError: Connection closed by server.
In client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | ConnectionError |
Connection closed by server. |
| Jedis | JedisConnectionException |
Unexpected end of stream. |
| node-redis | SimpleErrorTest with err.message.startsWith('DENIED') |
DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. ... |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisConnectionException |
Unable to connect to <host>/<unresolved>:<port>The cause is a RedisConnectionException with the DENIED message. |
| go-redis | io.EOF |
EOFThe server closes the connection after it sends the error, and go-redis reported EOF in our run, not the error text. |
| ioredis | Error |
Connection is closed.The server closes the connection after it sends the error. |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisConnectionException |
It was not possible to connect to the redis server(s). Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code.Connect raises this error when the server refuses the connection. |
| Predis | Predis\Connection\ConnectionException |
Stream is already at the end [tcp://<host>:<port>] |
| redis-rb | Redis::CannotConnectError |
EOFError (redis://<host>:<port>) (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::Io |
unexpected end of fileThe server closes the connection after it sends the error. The async API reports broken pipe. |
How to fix it
Protected mode keeps a server that has no password away from the network. The safest fix is to set a password. Protected mode then lets other computers connect, as long as they authenticate:
-
On the server's own computer, connect with
redis-cliand set a password for the default user:> CONFIG SET requirepass <password> OKTo keep the password after a restart, also set
requirepass <password>in the configuration file. For separate users with their own passwords, see access control lists (ACLs). -
Give the password to your app or client. See
NOAUTH.
If the server can only be reached from a network you trust, for example, while you test, you can turn protected mode off instead. Set protected-mode no in the configuration file, or start the server with --protected-mode no. Make sure that the server isn't reachable from the internet.
See Protected mode.