Search code examples
herokuredisconnection-stringredis-cli

Can I use redis-cli with a connection URL?


I am used to psql which I can use by feeding it the connection string without having to break it in different arguments, that is,

psql postgres://<username>:<password>@<host>:<port>

This is useful when I have such string from Heroku, for example. Can I do something similar with redis-cli? I want to feed it directly a connection string, such as the one that is stored on Heroku as environment variable when I install a Redis add-on. Is that possible? Example of the syntax I would like to use:

redis-cli redis://<username>:<password>@<host>:<port>

Solution

  • 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