Skip to the workspace
Pebellslearn by building
What is Redis?  ›  Capstone Project

Starting Redis and Connecting with redis-cli

Connecting using Redis CLI 12 minStart a Redis server with Docker, a package manager or a downloaded build, then connect with redis-cli on port 6379 and check the connection with PING.

redis / Starting Redis and Connecting with redis-cli

Explore each scene at your own pace.

01 · The rule

The rule

Starting Redis and Connecting with redis-cli

Before any of Wordcraft's counters or leaderboards can exist, you need a Redis server running and a way to type commands at it. There are several ways to install Redis, but they all end at the same place: a server listening on a port and a client that talks to it.

The rule

Start the server, connect with redis-cli, and PING until it says PONG.

Start a server. Pick whichever route suits your machine:

# Docker: nothing to install except Docker itself
docker run -d --name redis -p 6379:6379 redis

# macOS with Homebrew
brew install redis
brew services start redis

# Debian or Ubuntu
sudo apt install redis-server

# Any system: run the server binary directly
redis-server

Docker is the quickest to try and the easiest to remove. A package manager (Homebrew, apt) installs Redis as a system service that starts with the machine. You can also download the source release and build it with make, or use a pre-compiled binary if one is packaged for your platform; either way you then start the server by running redis-server. By default the server listens on port 6379.

Connect. redis-cli is the command-line client that ships with Redis. With no options it connects to 127.0.0.1 on port 6379; -h and -p choose another host or port. In Docker you can run the client inside the container:

docker exec -it redis redis-cli

Check it. Your first command should be PING:

127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET greeting hello
OK
127.0.0.1:6379> GET greeting
"hello"

The prompt shows the host and port you are connected to. Command names are not case-sensitive (ping works too), but key names are: greeting and Greeting are different keys.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.