There are two ways to connect remote redis server using redis-cli
:
redis-cli -h host -p port
If your instance is password protected
redis-cli -h host -p port -a password
e.g. if my-web.cache.amazonaws.com
is the host url and 6379
is the port
Then this will be the command:
redis-cli -h my-web.cache.amazonaws.com -p 6379
if 92.101.91.8
is the host IP address and 6379
is the port:
redis-cli -h 92.101.91.8 -p 6379
command if the instance is protected with password pass123
:
redis-cli -h my-web.cache.amazonaws.com -p 6379 -a pass123
uri
option in commandredis-cli -u redis://password@host:port
command in a single uri
form with username & password
redis-cli -u redis://username:password@host:port
e.g. for the same above host - port configuration command would be
redis-cli -u redis://[email protected]:6379
command if username is also provided user123
redis-cli -u redis://user123:[email protected]:6379
This detailed answer was for those who wants to check all options. For more information check documentation: Redis command line usage