Back to results for “Security”
Redis › Redis CLI & Basic Commands

What is redis-cli, and how do you use it to connect to and interact with a Redis server?

Beginner

Answer

redis-cli is the official command line tool for connecting directly to a Redis server, letting you run commands interactively and see their results immediately, which is useful for quick testing, troubleshooting, and learning how specific commands behave before using them in application code.
redis-cli -h localhost -p 6379
127.0.0.1:6379> SET greeting 'hello'
127.0.0.1:6379> GET greeting
Real-world example A developer uses redis-cli to quickly test how a new command behaves before writing the equivalent code in their application, confirming the exact syntax and expected response format.

Common follow-ups: How do you connect redis-cli to a remote Redis server with a password?;How do you exit the redis-cli interactive session?