Setting the REDIS_URL variable

6,855 views
Skip to first unread message

jdeel

unread,
Dec 2, 2016, 7:24:25 AM12/2/16
to Redis DB
I am new to Redis and I want to install it in a Ubuntu machine for Sidekiq.
In the redis-rb GitHub official page it is written that Redis with a default configuration is listening on localhost, port 6379.
Shall I assume that the REDIS_URL variable is by default already set to redis://localhost:6379 ?
Or, if I wish to use the REDIS_URL variable, am I supposed to do set it explicitly?

$ export REDIS_URL = redis://localhost:6379

I can only guess that setting the REDIS_URL variable has only sense if it is necessary to change the default configuration.
However I could not find documentation about it and the redis.conf files in the documentation do not contain any entry for REDIS_URL.

Jan-Erik Rediger

unread,
Dec 2, 2016, 7:32:37 AM12/2/16
to redi...@googlegroups.com
By default REDIS_URL is unset.
If no configuration is specified explicitely (either through passing
arguments or by setting the environment variable), redis-rb will use
localhost and port 6379.

If that's where your redis server is running, you don't need to set it
explicitely.

On Fri, Dec 02, 2016 at 04:21:25AM -0800, jdeel wrote:
> I am new to Redis and I want to install it in a Ubuntu machine for Sidekiq.
> In the redis-rb GitHub official page <https://github.com/redis/redis-rb> it
> is written that Redis with a default configuration is listening on localhost,
> port 6379.
> Shall I assume that the REDIS_URL variable is by default already set to
> redis://localhost:6379 ?
> Or, if I wish to use the REDIS_URL variable, am I supposed to do set it
> explicitly?
>
> $ export REDIS_URL = redis://localhost:6379
>
> I can only guess that setting the REDIS_URL variable has only sense if it
> is necessary to change the default configuration.
> However I could not find documentation about it and the redis.conf files in
> the documentation do not contain any entry for REDIS_URL.
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

jdeel

unread,
Dec 2, 2016, 12:36:45 PM12/2/16
to Redis DB, jan...@fnordig.de
Thanks janerik!

jdeel

unread,
Dec 2, 2016, 2:53:02 PM12/2/16
to Redis DB, jan...@fnordig.de
In the default redis.conf the number of databases is set to 16, and the default database is DB 0.
Some documentation says that it is not uncommon to use different Redis databases for development and for tests.
I am wondering whether would it be convenient to use REDIS_URL for such purposes as setting DB 1 for tests and leaving DB 0 for development.
If I set REDIS_URL = redis://localhost:6379/1 and fetch REDIS_URL inside tests would DB 1 be used only in test environment or also in development?
In other words setting REDIS_URL is useful when REDIS_URL needs to be used and explicitly called (as inside tests) or would affect server configuration?

方垚

unread,
Aug 11, 2020, 5:49:47 AM8/11/20
to Redis DB

URI syntax
Redis Standalone
redis://[password@]host [: port][/database][? [timeout=timeout[d|h|m|s|ms|us|ns]] [ &database=database] [&clientName=clientName]]
Redis Standalone (SSL)
rediss://[password@]host [: port][/database][? [timeout=timeout[d|h|m|s|ms|us|ns]] [ &database=database] [&clientName=clientName]]
Redis Standalone (Unix Domain Sockets)
redis-socket:// [password@]path[ ?[timeout=timeout[d|h|m|s|ms|us|ns]][&database=database] [&clientName=clientName]]
Redis Sentinel
redis-sentinel://[password@]host1 [: port1][, host2 [:port2]][, hostN [:portN]][/ database][? [timeout=timeout[d|h|m|s|ms|us|ns]] [ &sentinelMasterId=sentinelMasterId] [&database=database] [&clientName=clientName]]

I hope this can help
Reply all
Reply to author
Forward
0 new messages