Redis refused to accept your connection because it’s configured to require a password, and you didn’t provide one.

Here’s what’s happening:

Redis, by default, used to run without authentication. As it became more widely deployed, especially in cloud environments, running Redis open to the internet without a password became a massive security risk, leading to data theft and cryptojacking. To combat this, Redis introduced the requirepass directive. When requirepass is set in the Redis configuration, any client attempting to connect must first authenticate using the AUTH command with the correct password. Your client is trying to execute a command (likely PING or the initial connection handshake) before authenticating, and Redis is rightfully rejecting it with a NOAUTH error.

Here are the common reasons you’re seeing this and how to fix them:

  1. Client Library Default Behavior: Many Redis client libraries, especially older versions or those configured for a default "no auth" environment, don’t automatically send an AUTH command on connection.

    • Diagnosis: Check your client application’s configuration or documentation. Look for settings related to authentication, password, or AUTH command.
    • Fix: In your application code, explicitly provide the password when creating the Redis client instance. For example, in Python with redis-py:
      import redis
      r = redis.Redis(host='your_redis_host', port=6379, password='your_redis_password')
      
      Or in Node.js with ioredis:
      const Redis = require('ioredis');
      const redis = new Redis({
        host: 'your_redis_host',
        port: 6379,
        password: 'your_redis_password',
      });
      
    • Why it works: This tells the client library to send the AUTH your_redis_password command to Redis immediately after establishing the TCP connection, satisfying Redis’s authentication requirement.
  2. Incorrect Password in Client Configuration: You’ve configured a password in your client, but it’s simply the wrong one.

    • Diagnosis: Double-check the password set in your client application’s configuration against the password actually configured in your Redis server.
    • Fix: Update the password in your client configuration to match the requirepass value in redis.conf.
      # Example in Python
      r = redis.Redis(host='your_redis_host', port=6379, password='CORRECT_REDIS_PASSWORD')
      
    • Why it works: Redis compares the password provided via the AUTH command against its stored requirepass value. A match allows the connection to proceed.
  3. Redis requirepass Directive Not Set (or commented out): If you intended for Redis to have no password (which is highly discouraged for anything beyond local development), but you’re still getting NOAUTH, it might be that requirepass is set but commented out or the config file wasn’t reloaded.

    • Diagnosis: Connect to your Redis server using redis-cli and run CONFIG GET requirepass. If it returns an empty array [] or nil, then requirepass is not set. If you see a password, it is set.
      redis-cli
      127.0.0.1:6379> CONFIG GET requirepass
      1) "requirepass"
      2) "" # Or a password, if set
      
    • Fix: To disable authentication, edit your redis.conf file. Find the line # requirepass foobared and either delete the # to uncomment it and set it to an empty string, or comment out the line entirely, and then restart or reload Redis.
      # Example redis.conf snippet
      # requirepass foobared # Comment this out or change to:
      requirepass ""
      
      After editing redis.conf, restart the Redis service:
      sudo systemctl restart redis
      # or
      redis-server /etc/redis/redis.conf
      
    • Why it works: By setting requirepass to an empty string or commenting it out, you instruct Redis not to enforce authentication, allowing any client to connect without an AUTH command.
  4. Redis requirepass Directive IS Set, but Client Not Sending AUTH: This is the most common scenario. You know Redis has a password, but your client isn’t sending it.

    • Diagnosis: Use redis-cli to verify requirepass is set.
      redis-cli
      127.0.0.1:6379> CONFIG GET requirepass
      1) "requirepass"
      2) "your_redis_password"
      
      Then, try connecting without authentication from redis-cli itself (which should fail):
      redis-cli
      127.0.0.1:6379> PING
      (error) NOAUTH Authentication required.
      
      And then connect with authentication:
      redis-cli -a your_redis_password
      127.0.0.1:6379> PING
      PONG
      
    • Fix: As described in point 1, ensure your client application is configured with the correct password. If you are using a tool like redis-cli and have saved your password in an environment variable or config file, ensure that mechanism is correctly picking up the password. For redis-cli, you can use the -a flag:
      redis-cli -h your_redis_host -p 6379 -a your_redis_password
      
    • Why it works: Explicitly providing the password to the client library or tool ensures the AUTH command is sent, which Redis then validates.
  5. Redis Configuration Reloaded, but Not Restarted: If you edited redis.conf and used CONFIG REWRITE to save the changes, but didn’t restart Redis, the requirepass setting might not have taken effect immediately if it was a dynamic configuration directive that requires a restart. However, requirepass is a dynamic directive and CONFIG SET requirepass or a CONFIG REWRITE after editing redis.conf should apply it without a restart. If you’re seeing this, it’s likely a misunderstanding of when a restart is needed.

    • Diagnosis: Check redis-cli to see the current requirepass value: CONFIG GET requirepass. If it doesn’t match your redis.conf or your intended state, a restart is needed.
    • Fix: Restart the Redis service to ensure all configuration changes are loaded.
      sudo systemctl restart redis
      # or
      redis-server /etc/redis/redis.conf
      
    • Why it works: A full restart of the Redis server process ensures that the server reads its configuration file from disk and applies all directives, including requirepass, correctly.
  6. Proxy or Load Balancer Interference: If there’s a proxy (like HAProxy, Nginx, or a cloud provider’s load balancer) sitting in front of Redis, it might be stripping or not forwarding the AUTH command correctly.

    • Diagnosis: Bypass the proxy temporarily and connect directly to the Redis instance from your application’s host. If it works, the proxy is the issue. Inspect the proxy’s configuration for any rules that might affect Redis commands or TCP traffic.
    • Fix: Configure your proxy to allow the AUTH command to pass through to Redis, or ensure it’s correctly handling the Redis protocol. This is highly dependent on the specific proxy software. For example, with Nginx, you might need to ensure proxy_protocol is handled correctly or that no specific Redis command filtering is in place.
    • Why it works: The AUTH command needs to reach the Redis server to be processed. If a proxy is intercepting or modifying the traffic, it must be configured to allow this authentication step.

Once you’ve corrected your client configuration and ensured the Redis server is running with the expected requirepass setting, your next error might be a connection refused if Redis isn’t running or a timeout if network connectivity is an issue.

Want structured learning?

Take the full Redis course →