REDIS connection environment variable

redis

I have an application server that is connecting to an external redis server for pub/sub, I am currently using a redis python library, when I connect using the library it assumes the redis server is started locally at 127.0.0.1:6379. Is there an environment variable that sets the default redis connection to 127.0.0.1:6379? I can specify the server end point in my application code but I would prefer to use an environment variable if one is available.

Best Answer

It is not an environmental setting, but a default setting. Check the source code:

def __init__(self, host='localhost', port=6379, password=None,
...
)

Change it in the configuration file:

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
#port 6379

# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
# bind 127.0.0.1