Can I use redis-cli with a connection URL? Can I use redis-cli with a connection URL? heroku heroku

Can I use redis-cli with a connection URL?


No, at the moment (v3.2.1) redis-cli does not support the URI connection schema. If you want, you can make a feature or pull request for that in the Redis repository.

UPDATE:The -u option was released with Redis 4.0, see Release notes. For example:

redis-cli -u redis://user:pass@host:6379/0


For those who cannot wait for the next Redis release won't be able to update their redis-cli, I made a simple bash function that seems to work for my case (Heroku). This is to be added to ~/.bash_profile or ~/.bashrc:

function redis-url() {  # Get the first argument as the URL variable  url=$1  # Parse and generate the command: redis-cli -h [hostname] -p [port] -a [password]  cmd=`echo $url | sed 's_redis://\(.*\):\(.*\)@\(.*\):\(.*\)_redis-cli -h \3 -p \4 -a \2_'`  # Run the command  $cmd}

I can then type the following in my terminal:

redis-url redis://rediscloud:mysupersecurepassword@hostname.com:1234