Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Security and hardening

redis-cli warns that a password on the command line may not be safe

ErrorWarning: Using a password with '-a' or '-u' option on the command line interface may not be safe.

Short answer

redis-cli prints this warning because a password given as -a or inside a -u URI appears in the process list and in shell history. The documented safer route is the REDISCLI_AUTH environment variable; --askpass prompts for the password instead. The --no-auth-warning flag only hides the message, it fixes nothing.

  • Applies to redis-cli 7.4, redis-cli 8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find which form of the password you are passing. The warning appears for both -a and a URI with a password.

    history | grep -E 'redis-cli.*( -a | -u )'
  2. 2Match what you see, then jump to its fix

    1. 1The command contains -a followed by the passwordThe password is passed with -aFix
    2. 2The command has -u redis://user:password@hostThe password sits inside a -u URIFix
    3. 3The password already comes from a protected source and the warning clutters logsA script only needs the message goneFix

What does the error look like?

  • Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.

Cause 1 of 3

The password is passed with -a

1Check

-a takes the password as an argument. The Redis docs recommend the REDISCLI_AUTH environment variable instead, and say that -a wins when both are set.

ps -eo args | grep '[r]edis-cli'

2Fix

Put the password in the environment for that command only, or let redis-cli ask for it.

# read it without echo, then run the command
read -rs REDISCLI_AUTH && export REDISCLI_AUTH
redis-cli PING

# or be prompted by redis-cli itself
redis-cli --askpass PING

3Verify

The command answers PONG and prints no warning.

redis-cli PING

Confirmed by redis.io

Did this fix it?

Cause 2 of 3

The password sits inside a -u URI

1Check

The URI form redis://user:password@host:port/dbnum carries the password in the argument too, so it triggers the same warning.

echo "$REDIS_URL" | sed 's#//[^@]*@#//***@#'

2Fix

Split the URI: give the host and port as options and keep the password in REDISCLI_AUTH. This form signs in as the default user.

export REDISCLI_AUTH='...'
redis-cli -h redis.example.com -p 6379 PING

3Verify

The reply comes back without the warning.

redis-cli -h redis.example.com -p 6379 PING

Confirmed by redis.io

Did this fix it?

Cause 3 of 3

A script only needs the message gone

1Check

There is an option to silence the message. It does not hide the password from the process list.

redis-cli --help | grep -- '--no-auth-warning'

2Fix

Only use the option where the process list is not shared, for example inside a private container.

redis-cli --no-auth-warning -a "$REDIS_PASSWORD" PING

3Verify

No warning is printed.

redis-cli --no-auth-warning -a "$REDIS_PASSWORD" PING

Confirmed by redis.io

Did this fix it?

How do I stop it coming back?

  • Keep the password in a secret store or an environment file with tight permissions, not in scripts.
  • Set REDISCLI_AUTH from the secret store at the start of the job.
  • Avoid pasting commands with passwords into shared terminals or tickets.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.